-
Notifications
You must be signed in to change notification settings - Fork 13.3k
A generic way to wrap errors would be useful in the standard library #14419
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
Comments
trait WrapError<T> {
fn wrap_error(e: T) -> Self;
}
impl<T> WrapError<T> for T {
fn wrap_error(e: T) -> T {e}
}
fn wrap_error<T, E: WrapError<T> = T>(e: T) -> E {
WrapError::wrap_error(e)
}
macro_rules! try(
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(wrap_error(e)) })
) This would be backwards-compatible and allow the user to add custom wrappers - even have |
This is now implemented, closing. |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jun 5, 2023
fix: Fix proc-macro paths using incorrect CrateId's for `rust-project.json` workspaces
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Mar 20, 2025
TLDR ```diff - /// 01234 + /// 01234 12345 ``` Sometimes, in doc comments, there are 3 spaces + 1 instead of 4 spaces + 1. To make it coherent with the rest of the clippy codebase, I `fd -t f -X sed -E -i 's,///\s{4}(\S),/// \1,g'` and manually verified and fixed the relevant part of code that had bad indentation. ### Example ```rs /// fn a() { /// 01234 /// } ``` Becomes ```rs /// fn a() { /// 01234 /// } ``` changelog: none
This issue was closed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be useful in functions that can fail in different ways from the functions it calls itself, allowing something like:
The text was updated successfully, but these errors were encountered: