lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It might also be worth checking out this article by Henning Thielemann: https://wiki.haskell.org/Error_vs._Exception

I do believe he refers to an 'error' as an 'exception' at one point, but it's still an excellent read, especially since in Haskell, errors can be thrown from outside a monad, while exceptions generally cannot (i.e. exceptions have to be handled, while errors do not), unless, just like in Lua, you abuse the error function to throw exceptions.

Not that this is forbidden, but it is generally bad, and it creates a lot of confusion.
For example: in Haskell, the error function is supposed to throw errors, but an _error_, when caught, becomes an _exception_, which should only be used to print it as a _error_ message.

The article gives a few other examples in the section "When errors become exceptions".