Understanding Let It Crash
We used Task.Supervisor to isolate a process crash, but it may seem strange we didn’t prevent the crash by simply adding error handling in the send_email/1 function. In this particular case, we did this on purpose, just to simulate an unexpected exception. In practice, you should provide error handling when you expect an error to occur, and leave the rest to the supervisor as a last resort.
When discussing error handling for Elixir, the phrase let it crash is often used. As a result, some people assume that let it crash means that Erlang and Elixir developers don’t do any error handling, which is not the case. Pattern matching and the with macro in Elixir make working with {:ok, result} and {:error, msg} tuples easy, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access