View Source Credo.Check.Readability.PreferImplicitTry (Credo v1.6.4)
This check has a base priority of low
and works with any version of Elixir.
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
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.