Skip to main content

StructuredError

Struct StructuredError 

Source
pub struct StructuredError {
    pub message: String,
    pub location: ErrorLocation,
    pub error_type: ValidationErrorType,
    pub level: ErrorLevel,
    pub node_name: Option<String>,
    pub expected: Option<String>,
    pub found: Option<String>,
}
Expand description

Structured error for schema validation, compatible with libxml’s StructuredError.

Fields§

§message: String

Error message

§location: ErrorLocation

Location information (line, column, byte_offset, xpath)

§error_type: ValidationErrorType

Error type classification

§level: ErrorLevel

Error severity level

§node_name: Option<String>

Name of the element or attribute that caused the error

§expected: Option<String>

Expected value or type (for type mismatch errors)

§found: Option<String>

Actual value found (for type mismatch errors)

Implementations§

Source§

impl StructuredError

Source

pub fn new(message: impl Into<String>, error_type: ValidationErrorType) -> Self

Creates a new error with the given message and type.

Source

pub fn with_line(self, line: usize) -> Self

Sets the line number.

Source

pub fn with_column(self, column: usize) -> Self

Sets the column number.

Source

pub fn with_byte_offset(self, offset: usize) -> Self

Sets the byte offset.

Source

pub fn with_level(self, level: ErrorLevel) -> Self

Sets the error level.

Source

pub fn with_element_path(self, path: impl Into<String>) -> Self

Sets the element path (stored in location.xpath).

Source

pub fn with_node_name(self, name: impl Into<String>) -> Self

Sets the node name.

Source

pub fn with_expected(self, expected: impl Into<String>) -> Self

Sets the expected value.

Source

pub fn with_found(self, found: impl Into<String>) -> Self

Sets the found value.

Source

pub fn is_warning(&self) -> bool

Returns true if this is a warning.

Source

pub fn is_error(&self) -> bool

Returns true if this is an error or fatal.

Source

pub fn with_location(self, location: &ErrorLocation) -> Self

Sets location information from an ErrorLocation (merges non-None fields).

Source

pub fn set_location(self, location: ErrorLocation) -> Self

Sets the entire location, replacing any existing location.

Source

pub fn line(&self) -> Option<usize>

Returns the line number (convenience accessor).

Source

pub fn column(&self) -> Option<usize>

Returns the column number (convenience accessor).

Source

pub fn byte_offset(&self) -> Option<usize>

Returns the byte offset (convenience accessor).

Source

pub fn element_path(&self) -> Option<&str>

Returns the element path (convenience accessor).

Source

pub fn calculate_line_column(self, input: &str) -> Self

Calculates and sets line/column from byte_offset using the given input.

This is useful when you have a byte offset but need to display line/column.

Trait Implementations§

Source§

impl Clone for StructuredError

Source§

fn clone(&self) -> StructuredError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StructuredError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StructuredError

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for StructuredError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&StructuredError> for ErrorLocation

Source§

fn from(err: &StructuredError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more