Awesome Reviewers

Reviewer · Error Handling

Avoid masking exceptions

Secondary or cleanup logic must never hide the error that actually caused a failure, and exception handling scope must be as narrow as the code's intent.

Instruction

Secondary or cleanup logic must never hide the error that actually caused a failure, and exception handling scope must be as narrow as the code’s intent.

  1. Code that runs in a finally block or other cleanup/bookkeeping path (usage accounting, telemetry hooks, logging) must be wrapped in its own try/except so it can never replace the primary exception. For example, calling a usage hook in finally without guarding it can turn a meaningful ReasoningAgentExecutorError into an unrelated AttributeError, losing the real cause and traceback:
finally:
    if swarm is not None:
        try:
            self._add_usage(swarm)
        except Exception:  # accounting must never mask the run result
            pass
  1. Catch only the exception types you actually intend to handle. Avoid except BaseException (or bare except:) in generic control-flow drivers, since it also swallows KeyboardInterrupt, SystemExit, and, in async code, asyncio.CancelledError — this can prevent task cancellation from propagating and leave loops running when they should have stopped. Prefer except Exception and let truly exceptional signals propagate.

  2. Do not add blanket try/except blocks purely to suppress failures that indicate a real bug (e.g., wrapping module imports/exports). If something can legitimately fail at that point, let it raise so the underlying defect is visible and fixed, rather than silently degrading behavior.