Skip to content

Commit

Permalink
Remove unnecessary Exception and use specific Exception
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici committed Jul 18, 2024
1 parent 65b5412 commit 8779d20
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions conf/route_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,9 @@ def _netlink_route_handler(self, _, netlink_message: dict) -> None:
_: target
netlink_message (dict): The netlink message.
"""
try:
event = netlink_message.get('event')
except Exception:
logger.exception("Error parsing netlink message")
event = netlink_message.get('event')
if event is None:
logger.error("Netlink message does not include an event.")
return

logger.info("%s netlink event received.", event)
Expand Down Expand Up @@ -688,7 +687,7 @@ def _parse_route_entry_msg(self, route_entry: dict) -> Optional[RouteEntry]:
"""
try:
attr_dict = dict(route_entry["attrs"])
except Exception:
except (ValueError, KeyError):
logger.exception("Error parsing route entry message")
return None

Expand Down

0 comments on commit 8779d20

Please sign in to comment.