top | item 26191396

(no title)

jimis | 5 years ago

I find this article hard to read. But I believe its point stands. In Rust:

  - You bubble up errors using `?` operator,
  - then you get a nice error message.
  - However the location of the error is lost, the more complex the program, the harder it is to figure out where "permission denied" for example comes from.

discuss

order

jandrese|5 years ago

The whole article was basically the author figuring out how to get a full path error message instead of only getting the first or last component of the error path. Also, how to do it without also crashing the program entirely. Plus of course getting some context about the state of the program when it crashed, and without imposing the full stack trace overhead since this error was supposed to be available even on production builds.

nivenkos|5 years ago

You can attach context to the errors though.

It's only really a pain when writing libraries as you have to be so specific about your error types, etc.

Overall, it's probably still the "least bad" option compared to other languages' approaches (both Go and Python are painful for this for example). But it can be a lot of extra work sometimes, especially when just working on the first basics of a library crate.

magicalhippo|5 years ago

> You can attach context to the errors though.

I'd say you should attach context.

If there's problems accessing a file, then having an error message without the filename in it is near useless.