Use plain old integers for error handling.
- I’m not smart enough to understand the other error handling proposals.
- The simplest thing we can possibly do. This has been around since the dinosaurs, and for good reason.
errnohas problems in C of course, but
Resulteliminates most of them.
- It’s hard to imagine a newbie from another language who doesn’t already know how to use error codes. Prolog perhaps?
- Does not require nonexistent language features, runtime support or horrible performance (allocation).
- Introduce a new data structure to the standard library,
struct Errno(pub u32).
- Use it everywhere.
- Tell people to use it everywhere else.
- Optionally, maintain a library of globally unique aliases and related stuff.
- Live happily ever after.
The compiler cannot constrain the set of errors each function can emit. Careless use of
try! can lead to a situation much like C++ where only a recursive multi-library code audit will reveal all the exceptions thrown. RFC 70 does not solve this either.
No error chaining, if that’s a drawback.
RFC 70, exceptions, variadic templates, enum merging etc.
Whether there are any unresolved questions.