-
Notifications
You must be signed in to change notification settings - Fork 96
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
Handle errors from parser and resolver #65
Comments
I agree with the general direction. Thanks for writing this down. In our conversation, you mentioned using Using if let Some(resolved) = bundle.format("key") {
resolved
// Handle value.
.and_then(|value| ...)
// Handle value again, and possibly errors.
.or_else(|(value, errs)| ...)
} If instead if let Some((value, errs)) = bundle.format("key") {
// Handle errors.
errs.and_then(|errs| ...);
// Handle value.
value
} I don't know what the established pattern for such scenarios is in Rust. Is it better to have a dedicated branch for the error scenario with fallback ( |
I also realized that using Taking this into account, maybe we should return one of the following types?
|
I asked on rust user group - https://users.rust-lang.org/t/l10n-library-api-question/19967 |
This has been fixed by 21f3a31 |
This issue is a super-set of #62. We should unify how we handle errors from parser and resolver in the context.
We currently return
Result
fromadd_messages
andOption
fromformat
andformat_message
.I expect that what we really want are:
Result
fromadd_messages
which would return all parser errors collected during parsing and context errors collected during context building (currently, duplicated entry)Option<Result<>>
fromformat
andformat_message
whereOption
handles whether the value was there, andResult
would return the formatted message or the best string we can product and errors recorded during production.The text was updated successfully, but these errors were encountered: