Elixir automatically wraps the body of do in a try-block when one of the keywords rescue or catch is specified. They can also be used in conjunction with eachother.
I chose the simplest and most straightforward solution by duplicating a bit of code. I think it's easier to maintain than a loop or reducer. Especially since the keywords are limited and should appear in a specific order:
warning: "catch" should always come after "rescue" in def
test/exception_test.exs:36
Elixir automatically wraps the body of
do
in atry
-block when one of the keywordsrescue
orcatch
is specified. They can also be used in conjunction with eachother.This solves the following compilation error:
I chose the simplest and most straightforward solution by duplicating a bit of code. I think it's easier to maintain than a loop or reducer. Especially since the keywords are limited and should appear in a specific order: