buildtogether.tech
buildtogether.tech copied to clipboard
Discuss error handling more broadly (through historical practice, errno, exception, multi-return, Result)
The error chapter is very focused on throwing and catching exceptions, but that is one way out of many that errors have been and are being dealt with (and one with a lot of contemporary criticism, despite or maybe because its popularity).
I think it would be beneficial to address alternative ways to handle (or refuse to handle) errors, and their pros and cons:
- errno/global variable/static variable mutated to indicate error status
- exceptions
- multi return (like in Go) or multi argument (like in Node.js style traditional callbacks)
- container objects like
Result(this might also be a good time to talk aboutnullvsOptional, but maybe not) - in some cases, using types to make errors “impossible” (which implies segregating external error-prone code, like IO, to other parts of the program)
(I have thoughts about the pros and cons, but I’d first like to get feedback on the general idea of shrinking exceptions and expanding alternatives)