Hacker News new | ask | show | jobs
by Zezima 1031 days ago
Not the poster. What exactly are you asking about?

The usage of the error type the OP wrote is to get the line number of any error without using a macro on top of every single function in our crate.

The person who wrote `MyError` accomplished it by defining their error type as "something that can be constructed from any other error" (`impl From<E: StdErr> for MyError`) and additionally heap-allocated the original error with `Box::new(error)`.

So the usage would be to write one single error type in a crate which can "capture" or be constructed from any error type `E` and also prints out the line number of that error via `impl Display for MyError`.

1 comments

I'm looking for a usage example for the MyError type.
The code you wrote would be a valid use for `MyError`
Thanks!