Struct regex_automata::meta::BuildError
source · pub struct BuildError {
kind: BuildErrorKind,
}
Expand description
An error that occurs when construction of a Regex
fails.
A build error is generally a result of one of two possible failure
modes. First is a parse or syntax error in the concrete syntax of a
pattern. Second is that the construction of the underlying regex matcher
fails, usually because it gets too big with respect to limits like
Config::nfa_size_limit
.
This error provides very little introspection capabilities. You can:
- Ask for the
PatternID
of the pattern that caused an error, if one is available. This is available for things like syntax errors, but not for cases where build limits are exceeded. - Ask for the underlying syntax error, but only if the error is a syntax error.
- Ask for a human readable message corresponding to the underlying error.
- The
BuildError::source
method (from thestd::error::Error
trait implementation) may be used to query for an underlying error if one exists. There are no API guarantees about which error is returned.
When the std
feature is enabled, this implements std::error::Error
.
Fields§
§kind: BuildErrorKind
Implementations§
source§impl BuildError
impl BuildError
sourcepub fn pattern(&self) -> Option<PatternID>
pub fn pattern(&self) -> Option<PatternID>
If it is known which pattern ID caused this build error to occur, then this method returns it.
Some errors are not associated with a particular pattern. However, any errors that occur as part of parsing a pattern are guaranteed to be associated with a pattern ID.
§Example
use regex_automata::{meta::Regex, PatternID};
let err = Regex::new_many(&["a", "b", r"\p{Foo}", "c"]).unwrap_err();
assert_eq!(Some(PatternID::must(2)), err.pattern());
sourcepub fn size_limit(&self) -> Option<usize>
pub fn size_limit(&self) -> Option<usize>
If this error occurred because the regex exceeded the configured size limit before being built, then this returns the configured size limit.
The limit returned is what was configured, and corresponds to the maximum amount of heap usage in bytes.
sourcepub fn syntax_error(&self) -> Option<&Error>
pub fn syntax_error(&self) -> Option<&Error>
If this error corresponds to a syntax error, then a reference to it is returned by this method.
pub(crate) fn ast(pid: PatternID, err: Error) -> BuildError
pub(crate) fn hir(pid: PatternID, err: Error) -> BuildError
pub(crate) fn nfa(err: BuildError) -> BuildError
Trait Implementations§
source§impl Clone for BuildError
impl Clone for BuildError
source§fn clone(&self) -> BuildError
fn clone(&self) -> BuildError
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BuildError
impl Debug for BuildError
source§impl Display for BuildError
impl Display for BuildError
source§impl Error for BuildError
impl Error for BuildError
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
Auto Trait Implementations§
impl Freeze for BuildError
impl RefUnwindSafe for BuildError
impl Send for BuildError
impl Sync for BuildError
impl Unpin for BuildError
impl UnwindSafe for BuildError
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)