pub fn classify_error(err: &(dyn Error + 'static)) -> Option<EditErrorKind>Expand description
Classify a bare dyn Error (no anyhow required) into EditErrorKind.
Walks source() and peels EditError plus the CLI/tx typed errors
(NoMatchError, InvalidInputError, AmbiguousError, …). Use this from
non-anyhow agent hosts that store Box<dyn Error> or Arc<dyn Error>.
use patchloom::fallback::{classify_error, EditError, EditErrorKind};
let err: Box<dyn std::error::Error + Send + Sync> =
Box::new(EditError::new(EditErrorKind::NoMatch, "no matches for \"x\""));
assert_eq!(classify_error(err.as_ref()), Some(EditErrorKind::NoMatch));See #1659.