意外と複雑だったので、可能な限り情報を纏めてみました。 例外の種類 Elixir の例外には throw と error と exit という3種類があります。 どの例外も、投げた直後に処理を抜けて catch や rescue に飛ぶ(あるいはそれが無ければプロセスが終了する)という点では同じです。 throw throw はフロー制御のための例外です。 Elixir は、関数の途中で return したり、ループで条件を満たしたら break するというのが出来ません。 そういう時、処理の流れ(フロー)を変えるために throw を利用します。 throw を使うことで、例えば Enum.find/2 のような関数は以下のように書けます。 def find(enumerable, default \\ nil, fun) do try do for v <- enumerable do