Hacker News new | ask | show | jobs
by Kaali 3320 days ago
Monadic error handling is quite nice for domain specific errors, but for exceptional situations which are not supposed to happen, you still need some sort of an exception system. And even with domain error conditions, exceptions has a nice property of saving a stack trace, which can make error hunting a bit simpler.
1 comments

Exceptional situations as in crashes, like writing to 0x0 address?

Otherwise no, there is really no good reason for having some orthogonal value returning system that can jump up the stack until it's caught (if ever.)

Many situations that are often considered exceptional are really not: cannot connect to server, no such file or directory, cannot bind to port...

Any situation that prevents functionality from working and should not happen in normal flow is exceptional.

Including such connection failures or file open failures. They may have to be handled, but not at cost to the hot path.

You cannot typically just "eat" such an error with default behaviour and expect whatever relied on it to work properly.