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: StringError message
location: ErrorLocationLocation information (line, column, byte_offset, xpath)
error_type: ValidationErrorTypeError type classification
level: ErrorLevelError 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
impl StructuredError
Sourcepub fn new(message: impl Into<String>, error_type: ValidationErrorType) -> Self
pub fn new(message: impl Into<String>, error_type: ValidationErrorType) -> Self
Creates a new error with the given message and type.
Sourcepub fn with_column(self, column: usize) -> Self
pub fn with_column(self, column: usize) -> Self
Sets the column number.
Sourcepub fn with_byte_offset(self, offset: usize) -> Self
pub fn with_byte_offset(self, offset: usize) -> Self
Sets the byte offset.
Sourcepub fn with_level(self, level: ErrorLevel) -> Self
pub fn with_level(self, level: ErrorLevel) -> Self
Sets the error level.
Sourcepub fn with_element_path(self, path: impl Into<String>) -> Self
pub fn with_element_path(self, path: impl Into<String>) -> Self
Sets the element path (stored in location.xpath).
Sourcepub fn with_node_name(self, name: impl Into<String>) -> Self
pub fn with_node_name(self, name: impl Into<String>) -> Self
Sets the node name.
Sourcepub fn with_expected(self, expected: impl Into<String>) -> Self
pub fn with_expected(self, expected: impl Into<String>) -> Self
Sets the expected value.
Sourcepub fn with_found(self, found: impl Into<String>) -> Self
pub fn with_found(self, found: impl Into<String>) -> Self
Sets the found value.
Sourcepub fn is_warning(&self) -> bool
pub fn is_warning(&self) -> bool
Returns true if this is a warning.
Sourcepub fn with_location(self, location: &ErrorLocation) -> Self
pub fn with_location(self, location: &ErrorLocation) -> Self
Sets location information from an ErrorLocation (merges non-None fields).
Sourcepub fn set_location(self, location: ErrorLocation) -> Self
pub fn set_location(self, location: ErrorLocation) -> Self
Sets the entire location, replacing any existing location.
Sourcepub fn byte_offset(&self) -> Option<usize>
pub fn byte_offset(&self) -> Option<usize>
Returns the byte offset (convenience accessor).
Sourcepub fn element_path(&self) -> Option<&str>
pub fn element_path(&self) -> Option<&str>
Returns the element path (convenience accessor).
Sourcepub fn calculate_line_column(self, input: &str) -> Self
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
impl Clone for StructuredError
Source§fn clone(&self) -> StructuredError
fn clone(&self) -> StructuredError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructuredError
impl Debug for StructuredError
Source§impl Default for StructuredError
impl Default for StructuredError
Source§impl Display for StructuredError
impl Display for StructuredError
Source§impl From<&StructuredError> for ErrorLocation
impl From<&StructuredError> for ErrorLocation
Source§fn from(err: &StructuredError) -> Self
fn from(err: &StructuredError) -> Self
Auto Trait Implementations§
impl Freeze for StructuredError
impl RefUnwindSafe for StructuredError
impl Send for StructuredError
impl Sync for StructuredError
impl Unpin for StructuredError
impl UnsafeUnpin for StructuredError
impl UnwindSafe for StructuredError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more