-
Notifications
You must be signed in to change notification settings - Fork 72
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
Extend Option
with ok_or_eyre
?
#125
Comments
yes! This seems like a fantastic way to navigate that concern; I'd definitely not object to this addition. |
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
LeoniePhiline
added a commit
to LeoniePhiline/eyre
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements eyre-rs#125
ten3roberts
pushed a commit
that referenced
this issue
Dec 6, 2023
Previously, a closure and macro invocation was required to generate a static string error object from an `Option::None`. This change adds an extension trait, providing the `ok_or_eyre` method on the `Option` type. `Option::ok_or_eyre` accepts static error messages and creates `Report` objects lazily in the `None` case. Implements #125
Landed with #129's merge. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When discussing https://docs.rs/eyre/latest/eyre/index.html#context-and-option, a user remarked that a closure and macro invocation just for a static string error (as documented:
opt.ok_or_else(|| eyre!("new error message"))
) seemed cumbersome.The reasoning at the documentation's "
Context
andOption
" section does make sense -WrapErr
would indicate wrapping an error, where there is (literally)None
. This issue is not asking to implementWrapErr
forOption
.An extension trait, offering
ok_or_eyre
on theOption
type does seem useful to avoid closure + macro boilerplate:Is this something you would consider accepting as contribution? Names are of course up for bikeshedding.
The text was updated successfully, but these errors were encountered: