-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Error converting Box<Error+Send> to &Error #19279
Comments
Here's a demonstration of this error on play: http://is.gd/W3LG9a |
I believe this is a duplicate of #18524 |
My solution(rust 2018 nightly): #[derive(Debug)]
pub enum LibError {
EmptyVec,
DotEnvErr(Box<dyn Error>),
LogErr(Box<dyn Error>),
DatabaseErr(Box<dyn Error>),
}
impl Error for LibError {
fn description(&self) -> &str {
match self {
EmptyVec => "empty vectors not allowed",
DotEnvErr(e) => e.description(),
LogErr(e) => e.description(),
DatabaseErr(e) => e.description(),
}
}
fn cause(&self) -> Option<&Error> {
match self {
EmptyVec => None,
DotEnvErr(e) => Some(&**e),
LogErr(e) => Some(&**e),
DatabaseErr(e) => Some(&**e), //<———————— here
}
}
} |
lnicola
pushed a commit
to lnicola/rust
that referenced
this issue
Mar 10, 2025
Improve keyword completion for 'let' and 'let mut'
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to write an
Error
implementation which supports a set of "important" error, plus a catch-all for various minor errors caused by low-level subsystems. The code looks something like this:This yields the following error in
cause
:I should presumably be able to convert a
Box<Error+Send>
to an&Error
safely, but I can't figure out a way to do it.The text was updated successfully, but these errors were encountered: