use crate::error::{WokError, WokErrorSource};
pub trait WokErrorTrace {
fn trace(self, source: WokErrorSource) -> Self;
}
impl WokErrorTrace for WokError {
#[cfg(feature = "trace")]
fn trace(mut self, source: WokErrorSource) -> Self {
self.trace.push(source);
self
}
#[cfg(not(feature = "trace"))]
fn trace(self, _source: WokErrorSource) -> Self {
self
}
}
impl<T> WokErrorTrace for Result<T, WokError> {
#[cfg(feature = "trace")]
fn trace(mut self, source: WokErrorSource) -> Self {
if let Err(x) = &mut self {
x.trace.push(source);
}
self
}
#[cfg(not(feature = "trace"))]
fn trace(self, _source: WokErrorSource) -> Self {
self
}
}