Open Ploppz opened 6 years ago
Interesting idea! It's not possible now, but it would definitively be an improvement. Do you want to try a PR?
I can certainly give it a try. I looked at the code. My first take: I guess that location information should go into State
. Then perhaps this line should include both self.0
and self.1
(the State
) in a write!
statement, e.g. write!(f, "{}, {}", self.0, self.1.get_location())
.
Thoughts? Any better ideas?
You can't just take the top of the backtrace, since it would point to panic or something instead of where you want.
Another idea: use std::line!()
etc in bail!()
, storing the line number, file and function name in the State
. Meaning this will only work when you use bail!()
to return an error. Thoughts about this?
I have this function to print errors:
Example output:
I would really like if I could just have the information about where the error occurred, per error in the
for e in err.iter().skip(1)
loop, so that the output could just be e.g.Is this possible?
Or any other idea how to make it easier to immediately see the places in my code the error has jumped?