Argus.Analyses.ErrorHandling (Panoptes v0.13.0)

Copy Markdown View Source

Error handling analysis.

Detects error handling anti-patterns: bare rescues that silently swallow exceptions, trap_exit without matching handler, exit calls in GenServer callbacks, and ignored start results.

Output relations

  • swallowed_error(func) — catch-all rescue that silently discards exceptions (a handler that reifies the exception into a returned/ logged value or re-raises it is not flagged).
  • trap_exit_without_handler(mod) — traps exits but no handle_info callback at all.
  • trap_exit_without_exit_clause(mod, witness) — traps exits and has a handle_info/2, but no clause matches {:EXIT, ...} and none is a catch-all.
  • handle_info_without_catchall(mod, func) — a GenServer that monitors or traps exits defines handle_info/2 without a catch-all clause, so a message the runtime sends at a time of its choosing crashes it.
  • handle_info_partial(mod, func) — a GenServer or GenStage defines handle_info/2 without a catch-all and nothing in the module invites runtime messages; any stray message is still a FunctionClauseError.
  • exit_in_callback(func, target) — an exit signal (Process.exit/2) sent from a GenServer callback.
  • ignored_start_result(func, callee) — GenServer/Supervisor start result not checked.

Finding severities

swallowed_error, trap_exit_without_handler, trap_exit_without_exit_clause and ignored_start_result are :warning: each silently discards failure information — errors, exit signals, or failed starts — so the bug surfaces later, far from its cause. handle_info_without_catchall and handle_info_partial are :info: whether a stray message is worth crashing over is a judgement call; the first names a process that has invited such messages. exit_in_callback is :info: imperatively killing a process is frequently a deliberate protocol (handoff, conflict resolution), so it is surfaced for confirmation rather than flagged as a defect.