pub struct BuildError { /* private fields */ }
meta
only.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
.
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.
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
Available on crate feature std
only.
impl Error for BuildError
std
only.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,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 136 bytes