fix: replace broad except Exception with specific exception types
- jail_service: catch ValueError (fail2ban protocol error) instead of Exception - health.py: catch AttributeError (not OSError/TypeError) for defensive checks - ban_service: re-raise programming errors in geo lookup handlers - server_service: catch Fail2BanConnectionError, Fail2BanProtocolError, ValueError - config_writer: catch OSError instead of Exception Programming errors now bubble to global handler instead of being silently caught. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -159,12 +159,13 @@ async def _check_backend_cmd_supported(
|
||||
if state.backend_cmd_supported is not None:
|
||||
return state.backend_cmd_supported
|
||||
|
||||
# Probe: send the command and catch any exception.
|
||||
# Probe: send the command and catch only fail2ban protocol errors.
|
||||
# Programming errors (TypeError, AttributeError) bubble up to global handler.
|
||||
try:
|
||||
ok(await client.send(["get", jail_name, "backend"]))
|
||||
state.backend_cmd_supported = True
|
||||
log.debug("backend_cmd_supported_detected")
|
||||
except Exception:
|
||||
except ValueError:
|
||||
state.backend_cmd_supported = False
|
||||
log.debug("backend_cmd_unsupported_detected")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user