Credo v1.4.0 Credo.Check.Warning.RaiseInsideRescue 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 parameters for this check.