3 ms·
I'll definitely be thinking about errors in a new way, so thanks! > a success story, look no further than the Rust compiler itself; I don’t think it would be
by iudqnolq 4y ago
I'll definitely be thinking about errors in a new way, so thanks!
> a success story, look no further than the Rust compiler itself; I don’t think it would be an exaggeration to say that Rust enjoys the current popularity it does because of how good its error messages are, and how much effort was put into it.
The compiler diagnostics use a very different system than your error types. (eg https://github.com/rust-lang/rust/blob/master/compiler/rustc_borrowck/src/diagnostics/mod.rs#L120 https://github.com/rust-lang/rust/blob/master/compiler/rustc...).
I think your approach adds a lot of value to a very generic library, but that often all or most of the reasonable users of a library will only propagate. If so, advanced error messages can be a waste of time. For example, a library for writing to the terminal will probably be used by applications that exit with an error message if a write fails, so it's best API might be an opaque wrapper around a string with a very specific error message.
- SabrinaJewson 4y agoAbsolutely! The right kind of error type really depends on use-case — I targeted this kind of use case because I see people get it wrong most often, but it’s definitely not a one-size-fits-all solution.