ExSlop.Check.Warning.RescueWithoutReraise (ExSlop v0.4.0)

Copy Markdown View Source

Basics

This check is disabled by default.

Learn how to enable it via .credo.exs.

This check has a base priority of normal and works with any version of Elixir.

Explanation

A rescue that logs the error but doesn't re-raise or return it silently swallows failures. Callers will never know something went wrong.

# bad — logs then returns a generic atom
rescue
  e ->
    Logger.error("Failed: #{inspect(e)}")
    :error

# good — log and re-raise
rescue
  e ->
    Logger.error("Failed: #{Exception.message(e)}")
    reraise e, __STACKTRACE__

# good — return the actual exception info
rescue
  e in RuntimeError ->
    {:error, Exception.message(e)}

Check-Specific Parameters

There are no specific parameters for this check.

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.