Background
Both try/rescue and try/catch are error handling techniques in Elixir. According the corresponding chapter in the introduction guide.
Errors can be rescued using the
try/rescueconstruct
On the other hand,
throwandcatchare reserved for situations where it is not possible to retrieve a value unless by usingthrowandcatch.
Doubts
I have a brief understanding that rescue is for errors. While catch is for any value.
However,
- When should I make use of the error handling mechanisms in Elixir?
- What are the differences between them in detail?
- How should I pick one to use in a specific use case?
- What exactly are 'the situations where it is not possible to retrieve a value unless by using
throwandcatch'?
try/catchall errors. You should use supervisors when error occured to make your app robust or use raise whenever error should occur. - PatNowak