pub enum Error {
InvalidAriaAttribute {
attribute: String,
message: String,
},
WcagValidationError {
level: WcagLevel,
message: String,
guideline: Option<String>,
},
HtmlTooLarge {
size: usize,
max_size: usize,
},
HtmlProcessingError {
message: String,
source: Option<Box<dyn Error + Send + Sync>>,
},
MalformedHtml {
message: String,
fragment: Option<String>,
},
}Expand description
Enum to represent possible accessibility-related errors.
§Examples
use html_generator::accessibility::Error;
let err = Error::InvalidAriaAttribute {
attribute: "aria-foo".into(),
message: "unknown".into(),
};
assert!(err.to_string().contains("aria-foo"));Variants§
InvalidAriaAttribute
Error indicating an invalid ARIA attribute.
WcagValidationError
Error indicating failure to validate HTML against WCAG guidelines.
Fields
HtmlTooLarge
Error indicating the HTML input is too large to process.
HtmlProcessingError
Error indicating a failure in processing HTML for accessibility.
Fields
MalformedHtml
Error indicating malformed HTML input.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for HtmlError
Converts an accessibility error into the library-wide
crate::error::HtmlError so callers can use ? across module
boundaries without an explicit .map_err.
impl From<Error> for HtmlError
Converts an accessibility error into the library-wide
crate::error::HtmlError so callers can use ? across module
boundaries without an explicit .map_err.
The mapping is lossy on purpose: it collapses structured data such as
HTML fragments and WCAG conformance levels into the
crate::error::HtmlError::Accessibility variant’s message
string. If you need the full structured error, match on the
originating Error directly before converting.
§Examples
use html_generator::accessibility::Error;
use html_generator::error::HtmlError;
let acc_err = Error::InvalidAriaAttribute {
attribute: "aria-foo".to_string(),
message: "not a recognised attribute".to_string(),
};
let html_err: HtmlError = acc_err.into();
assert!(matches!(html_err, HtmlError::Accessibility { .. }));Source§impl From<TryFromIntError> for Error
From implementation for TryFromIntError
impl From<TryFromIntError> for Error
From implementation for TryFromIntError