use std::fmt; #[derive(Debug, Clone)] pub struct OxideError { pub message: String, pub span: (usize, usize), } impl fmt::Display for OxideError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{} at {:?}", self.message, self.span) } } impl std::error::Error for OxideError {} impl From for OxideError { fn from(diag: oxc_diagnostics::OxcDiagnostic) -> Self { let span = diag .labels .clone() .and_then(|labels| labels.first().map(|l| (l.offset(), l.offset() + l.len()))) .unwrap_or((0, 0)); OxideError { message: diag.message.to_string(), span, } } }