-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Vec<ParserError>
with opaque Error type.
#176
Comments
Well I don't know about the specific requirements for your error type but I would say creating a newtype that contains the list of errors, and itself also implements pub struct ParserErrors(Vec<ParserError>);
impl std::error::Error for ParserErrors {
// impl body
} |
@XAMPPRocky I am polishing I started thinking about your example, and I feel like a model of encapsulating list of errors just to implement I'm open to try to fix that, but I'm trying to see if there's a more natural solution. |
FWIW, my preferred error handling libraries are
I mean, in general I've never seen an API return As I mentioned above, you can't use the fn main() -> Result<(), Box<dyn std::error::Error>> {
// Returns Result<Vec<FluentResource>, std::io::Error>
let result = read_from_dir("path")?;
let mut bundle = FluentBundle::new(vec![unic_langid::langid!("en-US")]);
for resource in &result {
bundle.add_resource(resource)?;
}
Ok(())
} What awkwardness to foresee in using an opaque wrapper over |
It feels a bit as if I had a In my ideal world, we'd start handling lists of errors alongside single errors and |
I opened #219 to discuss the API signature of the parser. @XAMPPRocky I'd love your feedback there and if you know other people who may be able to help make a decision there, please, send them the link to that issue! |
Also for cross reference, #323 has discussion of several different issues with |
Currently in a few places fluent error type is vector of errors that allows you to display multiple syntax errors, but
Vec<T>
wasn't designed as an error type and as such when you're building a library on-top of fluent, where you just want to propagate the error using an error handling library or?
, you have to write quite a bit of boilerplate to correctly handle it.The text was updated successfully, but these errors were encountered: