Difference between try / rescue and try / throw

Semantically:

  • A throw is meant to be caught by you (typically within the same module that throws), can be any term

  • An error is when something goes wrong (typically not rescued), it is an exception in Elixir

  • An exit is when a process is crashing (typically not caught), can be any term

throws are handled by catchs, errors are handled by rescues. If I had a magic wand, exit would not be part of the language, especially because it is often mixed with the separate exit signal, but it exists in Erlang, so we have to support it, hence the catch kind, reason -> notation.

PRs to improve the docs are always welcome.