@eniko I gather the Rust Way is to have a return value that can be either an error or a value (a "Result"). The language then forces you to handle it (you can't pass a Result<foo, err> where a foo is needed), but gives you robust ergonomics on how to handle it, including:
foo().unwrap() (to make it crash if there's an error)
match foo() (a switch on steroids that forces you to handle both possibilities)
foo()? to bubble up the error and otherwise give you the value
In my limited experience that works quite well.
@eniko @bean Hm. To me it feels more like exception handling, at least when using the question mark operator.
But with the benefit that there are compact, inline ways of (selectively) intercepting those errors, and that they have a value representation (which is particularly useful when you need to represent an operation that *partly* failed, like a batch operation). That's something I miss in eg. JS.
(Also I think a lot of the hate for exceptions is bandwagoning and only a very small part of it is based in the genuine criticisms, tbh.)