pub struct Diagnostic {
pub severity: Severity,
pub code: Option<String>,
pub message: String,
pub primary: Option<Location>,
pub hint: Option<String>,
pub source: Option<Box<dyn Error + Send + Sync>>,
}Expand description
Structured diagnostic information
Fields§
§severity: SeverityError severity level
code: Option<String>Optional error code (e.g., “E001”, “typst::syntax”)
message: StringHuman-readable error message
primary: Option<Location>Primary source location
hint: Option<String>Optional hint for fixing the error
source: Option<Box<dyn Error + Send + Sync>>Source error that caused this diagnostic (for error chaining) Note: This field is excluded from serialization as Error trait objects cannot be serialized
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn with_location(self, location: Location) -> Self
pub fn with_location(self, location: Location) -> Self
Set the primary location
Sourcepub fn with_source(self, source: Box<dyn Error + Send + Sync>) -> Self
pub fn with_source(self, source: Box<dyn Error + Send + Sync>) -> Self
Set error source (chainable)
Sourcepub fn source_chain(&self) -> Vec<String>
pub fn source_chain(&self) -> Vec<String>
Get the source chain as a list of error messages
Sourcepub fn fmt_pretty(&self) -> String
pub fn fmt_pretty(&self) -> String
Format diagnostic for pretty printing
Sourcepub fn fmt_pretty_with_source(&self) -> String
pub fn fmt_pretty_with_source(&self) -> String
Format diagnostic with source chain for debugging
Trait Implementations§
Source§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl Display for Diagnostic
impl Display for Diagnostic
Source§impl From<&Diagnostic> for SerializableDiagnostic
impl From<&Diagnostic> for SerializableDiagnostic
Source§fn from(diag: &Diagnostic) -> Self
fn from(diag: &Diagnostic) -> Self
Converts to this type from the input type.
Source§impl From<Diagnostic> for SerializableDiagnostic
impl From<Diagnostic> for SerializableDiagnostic
Source§fn from(diag: Diagnostic) -> Self
fn from(diag: Diagnostic) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Diagnostic
impl !RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl !UnwindSafe for Diagnostic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more