View Source Credo.Check.Readability.PreferImplicitTry (Credo v1.7.0)

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

explanation

Explanation

Prefer using an implicit try rather than explicit try if you try to rescue anything the function does.

For example, this:

def failing_function(first) do
  try do
    to_string(first)
  rescue
    _ -> :rescued
  end
end

Can be rewritten without try as below:

def failing_function(first) do
  to_string(first)
rescue
  _ -> :rescued
end

Like all Readability issues, this one is not a technical concern. The code will behave identical in both ways.

check-specific-parameters

Check-Specific Parameters

There are no specific parameters for this check.

general-parameters

General Parameters

Like with all checks, general params can be applied.

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