We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Let's say I want to have a common prefix to all my errors, like:
#[derive(Error)] enum MatrixParseError { #[error("Couldn't parse matrix: foo")] Foo #[error("Couldn't parse matrix: bar")] Bar }
It would be cool to have the ability to specify such a prefix. (E.g. as [error("Couldn't parse matrix: {}")] on the enum.)
[error("Couldn't parse matrix: {}")]
Do you think you could add that? Or do you recommend another idiomatic way of achieving this behavior?
The text was updated successfully, but these errors were encountered:
You can extract the common part into a wrapping struct:
#[derive(Debug, Error)] #[error("Couldn't parse matrix: {}")] struct MatrixParseError(#[from] MatrixParseErrorKind); #[derive(Debug, Error)] enum MatrixParseErrorKind { #[error("foo")] Foo #[error("bar")] Bar }
Sorry, something went wrong.
Right, thank you!
It would still be great to be able to do this without an extra wrapping struct.
No branches or pull requests
Let's say I want to have a common prefix to all my errors, like:
It would be cool to have the ability to specify such a prefix. (E.g. as
[error("Couldn't parse matrix: {}")]
on the enum.)Do you think you could add that? Or do you recommend another idiomatic way of achieving this behavior?
The text was updated successfully, but these errors were encountered: