You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
no_nested_try_catch reports a warning on a try…catch block that's not really nested within another.
To Reproduce
Run Elvis on the following module:
-module(example).
-export([example/0]).
%% @doc If this fails in do:something/0, we handle the error.%% But if it fails in do:something_else/2, we ignore it.example() ->trydo:something() of
{ok, KeepGoing} ->
trydo:something_else("and", KeepGoing)
catch_:_ -> {ignore, errors, here}
endcatchKind:Error ->
{Kind, Error}
end.
You'll get the following warning:
#src/example.erl [FAIL]
- no_nested_try_catch (https://github.com/inaka/elvis_core/tree/main/doc_rules/elvis_style/no_nested_try_catch.md)
- Nested try...catch block starting at line 10.
Expected Behavior
No warnings, since the second try…catch is not really nested within the first one (i.e., it's not try … try … catch … end … catch … end, which is what the rule tries to prevent).
Additional Context
This equivalent version of the code works:
-module(example).
-export([example/0]).
%% @doc If this fails in do:something/0, we handle the error.%% But if it fails in do:something_else/2, we ignore it.example() ->Result=trydo:something()
catchKind:Error ->
{Kind, Error}
end,
caseResultof
{ok, KeepGoing} ->
trydo:something_else("and", KeepGoing)
catch_:_ -> {ignore, errors, here}
end;
{Kind, Error} ->
{Kind, Error}
end.
The text was updated successfully, but these errors were encountered:
Bug Description
no_nested_try_catch
reports a warning on atry…catch
block that's not really nested within another.To Reproduce
Run Elvis on the following module:
You'll get the following warning:
Expected Behavior
No warnings, since the second
try…catch
is not really nested within the first one (i.e., it's nottry … try … catch … end … catch … end
, which is what the rule tries to prevent).Additional Context
This equivalent version of the code works:
The text was updated successfully, but these errors were encountered: