projectfluent / fluent-rs

Rust implementation of Project Fluent
https://projectfluent.org
Apache License 2.0
1.05k stars 95 forks source link

Implement std::error::Error for ParserError #186

Closed Michael-F-Bryan closed 4 years ago

Michael-F-Bryan commented 4 years ago

Implementing std::error::Error and Display for ParserError can make handling parser errors and notifying the user a bit easier. I had to implement my own logic for this, and matching on each ErrorKind variant can be annoying.

I'm not sure if we want the Display impl to just show the reason parsing failed (i.e. defer to the self.kind impl), or whether we also want to mention pos in the error message. I believe pos represents the index into the string and not line/column numbers, so it's not very useful for a human wanting to fix the parse error.

zbraniecki commented 4 years ago

that looks good, thank you!