add impl From io::Error and dyn Error for ShellError

This commit is contained in:
xiuxiu62 2021-10-05 12:54:30 -07:00
parent c4ea398160
commit 9d49618e87

View File

@ -97,4 +97,20 @@ pub enum ShellError {
#[label("{destination_message}")]
destination_span: Span,
},
#[error("Move not possible")]
#[diagnostic(code(nu::shell::move_not_possible_single), url(docsrs))]
MoveNotPossibleSingle(String, #[label("{0}")] Span),
}
impl From<std::io::Error> for ShellError {
fn from(input: std::io::Error) -> ShellError {
ShellError::InternalError(format!("{:?}", input))
}
}
impl From<Box<dyn std::error::Error + Send + Sync>> for ShellError {
fn from(input: Box<dyn std::error::Error + Send + Sync>) -> ShellError {
ShellError::InternalError(format!("{:?}", input))
}
}