ExSlop.Check.Warning.BlanketRescue (ExSlop v0.4.1)

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 high and works with any version of Elixir.

Explanation

rescue _ -> or rescue _e -> that returns nil or a generic error tuple swallows all exceptions, making bugs invisible.

This is the most common AI slop pattern in Elixir. The AI adds blanket rescues to make code "robust", but it actually hides crashes that would surface real problems.

# bad — swallows everything
try do
  do_something()
rescue
  _ -> nil
end

# bad — generic string loses all context
rescue
  _e -> {:error, "Something went wrong"}

# good — rescue specific exceptions
rescue
  e in [ArgumentError, RuntimeError] ->
    Logger.warning("Failed: #{Exception.message(e)}")
    {:error, :invalid_input}

# good — let it crash (the BEAM way)
do_something()

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.