Awesome Reviewers

Reviewer · Error Handling

Preserve exception context

When handling errors, never let secondary or cleanup logic (especially in `finally` blocks, wrappers, or bookkeeping code) silently replace or mask the original exception. Auxiliary work such as usage/telemetry accounting, logging, or state cleanup must be wrapped so its own failures cannot propagate and hide the real error:

Instruction

When handling errors, never let secondary or cleanup logic (especially in finally blocks, wrappers, or bookkeeping code) silently replace or mask the original exception. Auxiliary work such as usage/telemetry accounting, logging, or state cleanup must be wrapped so its own failures cannot propagate and hide the real error:

finally:
    if swarm is not None:
        try:
            self._add_usage(swarm)
        except Exception:  # accounting must never mask the run result
            pass

When an error does need to propagate through nested calls (e.g. serialization of nested objects), use exception chaining (raise ... from error) rather than re-raising a flattened message, so the full path down to the root cause is preserved in the traceback and visible via __cause__.

Likewise, favor explicit validation and specific, actionable error messages over letting malformed input fall through to a generic exception or silent incorrect behavior. Guard edge cases up front (e.g. reject empty/invalid arguments, catch expected exception types like UnicodeDecodeError and return a clear message) instead of letting a low-level stack trace or a mis-bound call surface as the only diagnostic. Where a helper’s behavior depends on assumptions about another object’s interface (e.g. constructor signatures), prefer failing loudly and specifically over quietly producing wrong results.