shepmaster / snafu

Easily assign underlying errors into domain-specific errors while adding context
https://docs.rs/snafu/
Apache License 2.0
1.39k stars 60 forks source link

Print multi-line errors on their own lines in `Report` #435

Open judemille opened 8 months ago

judemille commented 8 months ago

I've run into a funny problem -- ParseErrors from winnow get displayed on multiple lines. If, for example, the first line contains a line that has an error in it, and then the second line contains a caret pointing to the text, the current Display impl on Report will mess that up.

Fixing this should be simple -- I can probably implement it fairly easily after some discussion on how best to go about fixing it. I figure the best solution is to break multi-line errors onto their own lines, and then add a line or two of padding after, before displaying the next error.

shepmaster commented 8 months ago

Can you show what their error looks like when formatted by itself and then what it looks like from Report?

judemille commented 7 months ago

Here is an example where I send the error through .map_err(|e| { eprintln!("parse error:\n\n{}\n\n", e.cause().unwrap()); e }):

The first output is my map_err, the second is the Report. image

The faulty column is SIDBY___.