error-stack: How to implicitly wrap errors? #3919
-
#[derive(Error, Debug)]
pub enum CliError {
#[error("{0}")]
Wrapped(clipboard_history_core::Error),
...
}
impl From<clipboard_history_core::Error> for CliError {
fn from(value: clipboard_history_core::Error) -> Self {
CliError::Wrapped(value)
}
} But the problem is that if I have a function return
Of course I can just use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I don't really understand what you're trying to achieve with your provided example. The code snippet does not use |
Beta Was this translation helpful? Give feedback.
Yes, the best option here is using
.map_err(CliError::from)
as theCliError
does contain the full error.If you're willing to change your
enum CliError
it's possible to leterror-stack
handle this properly, e.g.:Th…