Credo.Check.Warning.RaiseInsideRescue (Credo v1.5.0) View Source

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

Explanation

Using Kernel.raise inside of a rescue block creates a new stacktrace.

Most of the time, this is not what you want to do since it obscures the cause of the original error.

Example:

# preferred

try do
  raise "oops"
rescue
  error ->
    Logger.warn("An exception has occurred")

    reraise error, System.stacktrace
end

# NOT preferred

try do
  raise "oops"
rescue
  error ->
    Logger.warn("An exception has occurred")

    raise error
end

Configuration parameters

There are no specific parameters for this check.

Like with all checks, general params can be applied.

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