DEV Community


Discussion on: Errors Are Not Exceptions

stereobooster profile image

You may be interested in how Pony handles errors

An error is raised with the command error. At any point, the code may decide to declare an error has occurred. Code execution halts at that point, and the call chain is unwound until the nearest enclosing error handler is found. This is all checked at compile time so errors cannot cause the whole program to crash.

They look like exceptions (try/catch), but they are not. Because you can't actually use exception as value which carries message.

Also this maybe interesting (this is about Go): Rob Pike Reinvented Monads

In JS/TS we also have errors as values (idea copied from Monads in Haskell): io-ts.

olexandrpopov profile image
Oleksandr Popov

You also might be interested in Either monad from fp-ts library.