pub struct Diagnostic {
pub severity: Severity,
pub code: Option<String>,
pub message: String,
pub location: Option<Location>,
pub hint: Option<String>,
pub source_chain: Vec<String>,
}Expand description
Structured diagnostic information.
source_chain is a flat list of error messages from any attached
std::error::Error cause chain, eagerly walked at construction time so
the diagnostic remains trivially Clone and fully serializable across
every binding boundary.
Fields§
§severity: SeverityError severity level
code: Option<String>Optional error code (e.g., “E001”, “typst::syntax”)
message: StringHuman-readable error message
location: Option<Location>Primary source location
hint: Option<String>Optional hint for fixing the error
source_chain: Vec<String>Flattened cause chain (outermost first).
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: &(dyn Error + 'static)) -> Self
pub fn with_source(self, source: &(dyn Error + 'static)) -> Self
Attach an error cause chain, walked eagerly into source_chain.
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 Clone for Diagnostic
impl Clone for Diagnostic
Source§fn clone(&self) -> Diagnostic
fn clone(&self) -> Diagnostic
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Diagnostic
impl Debug for Diagnostic
Source§impl<'de> Deserialize<'de> for Diagnostic
impl<'de> Deserialize<'de> for Diagnostic
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Diagnostic
impl Display for Diagnostic
Source§impl PartialEq for Diagnostic
impl PartialEq for Diagnostic
Source§fn eq(&self, other: &Diagnostic) -> bool
fn eq(&self, other: &Diagnostic) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for Diagnostic
impl Serialize for Diagnostic
impl StructuralPartialEq for Diagnostic
Auto Trait Implementations§
impl Freeze for Diagnostic
impl RefUnwindSafe for Diagnostic
impl Send for Diagnostic
impl Sync for Diagnostic
impl Unpin for Diagnostic
impl UnsafeUnpin 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