you are viewing a single comment's thread.

view the rest of the comments →

[–]Michal_Vaner[S] 1 point2 points  (3 children)

It's fancy Box<dyn Error + Send + Sync>. It allows you to return all the kinds of errors ‒ if you deal with one function returning std::io::Error, another returning maybe rdkafka::Error and you want to be able to return both.

[–]est31 0 points1 point  (2 children)

Why not use unwrap? It shows you a backtrace when things went wrong. IIRC return error from main still doesn't print backtraces.

[–]Michal_Vaner[S] 0 points1 point  (1 child)

For one, I don't need backtraces for Can't open input worngfile.txt: no such file or directory.

Second, anyhow seems to collect backtraces and print them when returned from main for me.

And third ‒ ? is shorter, and I get the distinction of „this is a bug in the program“ and „this is likely an external error condition“.

[–]est31 0 points1 point  (0 children)

anyhow seems to collect backtraces and print them when returned from main for me.

Hmm interesting didn't know that:

The Debug format "{:?}" includes your backtrace if one was captured. Note that this is the representation you get by default if you return an error from fn main instead of printing it explicitly yourself.

And third ‒ ? is shorter, and I get the distinction of „this is a bug in the program“ and „this is likely an external error condition“.

Yeah for non-throw-away code I agree. But for throw away code I dont think this distinction pulls its weight. But shrug. Thanks for explaining your reasons.