Singpolyma

singpolyma commented on Exceptions Best Practices at Reddit, saying

foo = do
if x then return y else error "something bad happened"

The problem is the usage of arbitrary string-based error messages. This makes it difficult to handle this exceptional case directly in a higher level in the call stack.

Also, this is not an example of an exception at all… it happens to be implemented using the same machinery in GHC, so you could treat it as one, but really it's a signal of programmer error. So not only is it "only a string" but it's also not a meant-to-be-caught exception of any kind.

in reply to @ 2016-2 21:21 UTC

Leave a Response