pub struct ErrorConfig {
pub mode: ErrorMode,
pub overrides: HashMap<ErrorType, ErrorOverride>,
}Expand description
Error handling configuration.
Controls how the parser handles common input errors. The configuration consists of a base mode plus optional per-error-type overrides.
Fields§
§mode: ErrorModeBase error handling mode.
overrides: HashMap<ErrorType, ErrorOverride>Per-error-type overrides.
Implementations§
Source§impl ErrorConfig
impl ErrorConfig
Sourcepub fn strict() -> Self
pub fn strict() -> Self
Create a strict configuration.
In strict mode, all non-standard input is rejected.
Sourcepub fn lenient() -> Self
pub fn lenient() -> Self
Create a lenient configuration.
In lenient mode, common errors are auto-corrected with warnings.
Sourcepub fn silent() -> Self
pub fn silent() -> Self
Create a silent configuration.
In silent mode, common errors are auto-corrected without warnings.
Sourcepub fn with_override(
self,
error_type: ErrorType,
override_: ErrorOverride,
) -> Self
pub fn with_override( self, error_type: ErrorType, override_: ErrorOverride, ) -> Self
Add an override for a specific error type.
§Example
use ferro_hgvs::error_handling::{ErrorConfig, ErrorType, ErrorOverride};
let config = ErrorConfig::lenient()
.with_override(ErrorType::LowercaseAminoAcid, ErrorOverride::Reject)
.with_override(ErrorType::ExtraWhitespace, ErrorOverride::SilentCorrect);Sourcepub fn set_override(&mut self, error_type: ErrorType, override_: ErrorOverride)
pub fn set_override(&mut self, error_type: ErrorType, override_: ErrorOverride)
Set an override for a specific error type.
This is the mutable version of with_override.
Sourcepub fn remove_override(&mut self, error_type: ErrorType)
pub fn remove_override(&mut self, error_type: ErrorType)
Remove an override for a specific error type.
Sourcepub fn action_for(&self, error_type: ErrorType) -> ResolvedAction
pub fn action_for(&self, error_type: ErrorType) -> ResolvedAction
Get the resolved action for an error type.
This applies the override if one exists, otherwise uses the base mode.
Sourcepub fn should_reject(&self, error_type: ErrorType) -> bool
pub fn should_reject(&self, error_type: ErrorType) -> bool
Returns true if the given error type should be rejected.
Sourcepub fn should_correct(&self, error_type: ErrorType) -> bool
pub fn should_correct(&self, error_type: ErrorType) -> bool
Returns true if the given error type should be corrected.
Sourcepub fn should_warn(&self, error_type: ErrorType) -> bool
pub fn should_warn(&self, error_type: ErrorType) -> bool
Returns true if the given error type should emit a warning.
Sourcepub fn preprocessor(&self) -> InputPreprocessor
pub fn preprocessor(&self) -> InputPreprocessor
Create a preprocessor with this configuration.
Trait Implementations§
Source§impl Clone for ErrorConfig
impl Clone for ErrorConfig
Source§fn clone(&self) -> ErrorConfig
fn clone(&self) -> ErrorConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more