3 ms·
Yeah Error handling bloat is a problem. You can use convenience functions: expression.expect("panic with this message if expression evaluates to an Err") You
by tmerr 11y ago
Yeah Error handling bloat is a problem.
You can use convenience functions: expression.expect("panic with this message if expression evaluates to an Err")
You can also use macros: try!(expression) makes it so if expression evaluates to an error it returns the error immediately, otherwise it does nothing.
This approach is still more verbose than using exceptions but on the flip side dealing with errors up front can make it easier to write reliable code.