pub fn raw_source<E>(err: E) -> RawSource<E>where
E: RawStdError,Expand description
Explicitly mark an opt-in raw std::error::Error as an unstructured source.
This is a narrow V1 escape hatch. It does not provide a blanket
E: StdError path, and it must not be used for StructError<_>.
Downstream crates may opt in their own raw StdError types by implementing
RawStdError, instead of relying on a blanket E: StdError fallback.
use std::fmt;
use orion_error::{raw_source, IntoAs, RawStdError, UvsReason};
#[derive(Debug)]
struct ThirdPartyError;
impl fmt::Display for ThirdPartyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "third-party failure")
}
}
impl std::error::Error for ThirdPartyError {}
impl RawStdError for ThirdPartyError {}
let result: Result<(), ThirdPartyError> = Err(ThirdPartyError);
let err = result
.map_err(raw_source)
.into_as(UvsReason::system_error(), "load failed")
.expect_err("expected structured error");
assert_eq!(err.source_ref().unwrap().to_string(), "third-party failure");ⓘ
use orion_error::{raw_source, RawStdError, StructError, UvsReason};
let structured = StructError::from(UvsReason::system_error());
let _ = raw_source(structured);