Hacker News new | ask | show | jobs
by tuvistavie 3700 days ago
Exceptions are not discouraged, using them for flow control is. There are I think a few reasons why exceptions are a being a little frowned upon.

The first one is that usually we do not want to rescue them, the let it crash philosophy. If an error happens, the the process will crash, it will be restarted, the error will be logged, and everyone will be happy.

In the case we really do want to handle an error, we can usually just use `case` or `with`, which are simpler, avoids to rescuing something we did not expect, as well as some pitfalls, for example the fact that recursive calls inside a `try` cannot be optimized to be tail-recursive, which can be an issue depending on the case.

However, I think it is fine to use exceptions if it can avoid deeply nested code, which was probably your case.