|Posted by arco|
in reply to Atila Neves
Posted in reply to Atila Neves
On Tuesday, 9 November 2021 at 11:37:49 UTC, Atila Neves wrote:
On Monday, 8 November 2021 at 14:23:15 UTC, Ola Fosheim Grøstad wrote:
On Monday, 8 November 2021 at 14:08:32 UTC, Atila Neves wrote:
I thought Rust error handling wasn't easy by default until they added the ? operator, at which point it became like exceptions but better.
Looks like syntactical sugar to me, but I am no Rust expert.
Correct, but then again, anything other than machine code is syntatical sugar. So is
throw new Exception("oh noes");
It means you now loose context
I don't see how.
and how do you log?
The same way in pretty much any and all programs written that handles exceptions - some outer loop, possibly in the main function.
To me that was always the issue with error handling without exceptions - how to easily just propagate it up (nearly always what one wants to do). I think they nailed it.
For simple situations maybe, but it looks like a hack, as far as I can tell from the docs.
I disagree. To me, it has all the convenience of exceptions with none of the drawbacks.
Actually, Rust also has exceptions but like Go, it's ashamed to admit it:
It's supposed to be used only for unrecoverable runtime errors (panics in Rust parlance).