Closed chrissimpkins closed 3 years ago
There are also some other crates for easier error handling, see e.g. https://rust-cli.github.io/book/tutorial/errors.html.
Thoughts about whether we need to implement much of the custom error type / handling here? Most of the error string reporting will come from the custom types in the norad lib and we simply spit out the file path involved and the error message from the library error.
You could make an error type that is basically
enum Error {
UfoError(norad::Error),
MyFormattingError(something),
// ...
}
The Display trait could then just pass through whatever the norad error does.
You could make an error type that is basically
enum Error { UfoError(norad::Error), MyFormattingError(something), // ... }
The Display trait could then just pass through whatever the norad error does.
I like it! Do you want to add this?
One day. Maybe I'll use https://github.com/dtolnay/anyhow instead.
Hm, you may want to lean more on Rust for the errors. You can make your own error container like https://github.com/linebender/norad/blob/master/src/error.rs#L11-L47 and then implement Display for it for formatting them for printing: https://github.com/linebender/norad/blob/master/src/error.rs#L150-L201
Originally posted by @madig in https://github.com/source-foundry/ufofmt/issues/5#issuecomment-886249143