pub struct BuildError { /* private fields */ }
Expand description
Describes errors that occur when building a Pattern
from a glob expression.
Glob expressions may fail to build if they cannot be parsed, violate rules, or cannot be compiled. Parsing errors occur when a glob expression has invalid syntax. Patterns must also follow rules as described in the repository documentation, which are designed to avoid nonsense expressions and ambiguity. Lastly, compilation errors occur only if the size of the compiled program is too large (all other compilation errors are considered internal bugs and will panic).
When the miette
feature is enabled, this and other error types implement the Diagnostic
trait. Due to a technical limitation, this may not be properly annotated in API documentation.
Implementations§
Source§impl BuildError
impl BuildError
Sourcepub fn locations(&self) -> impl Iterator<Item = &dyn LocatedError>
pub fn locations(&self) -> impl Iterator<Item = &dyn LocatedError>
Gets LocatedError
s detailing the errors within a glob expression.
This function returns an Iterator
over the LocatedError
s that detail where and why
an error occurred when the error has associated Span
s within a glob expression. For
errors with no such associated information, the Iterator
yields no items, such as
compilation errors.
§Examples
LocatedError
s can be used to provide information to users about which parts of a glob
expression are associated with an error.
use wax::Glob;
// This glob expression violates rules. The error handling code prints details about the
// alternative where the violation occurred.
let expression = "**/{foo,**/bar,baz}";
match Glob::new(expression) {
Ok(glob) => {
// ...
},
Err(error) => {
eprintln!("{}", error);
for error in error.locations() {
let (start, n) = error.span();
let fragment = &expression[start..][..n];
eprintln!("in sub-expression `{}`: {}", fragment, error);
}
},
}
Trait Implementations§
Source§impl Debug for BuildError
impl Debug for BuildError
Source§impl Diagnostic for BuildError
impl Diagnostic for BuildError
Source§fn code(&self) -> Option<Box<dyn Display + '_>>
fn code(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
. Ideally also globally unique, and documented
in the toplevel crate’s documentation for easy searching. Rust path
format (foo::bar::baz
) is recommended, but more classic codes like
E0123
or enums will work just fine.Source§fn help(&self) -> Option<Box<dyn Display + '_>>
fn help(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
. Do you have any
advice for the poor soul who’s just run into this issue?Source§fn url(&self) -> Option<Box<dyn Display + '_>>
fn url(&self) -> Option<Box<dyn Display + '_>>
Diagnostic
.Source§fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
fn labels(&self) -> Option<Box<dyn Iterator<Item = LabeledSpan> + '_>>
Diagnostic
’s Diagnostic::source_code
Source§fn severity(&self) -> Option<Severity>
fn severity(&self) -> Option<Severity>
ReportHandler
s to change the display format
of this diagnostic. Read moreSource§fn source_code(&self) -> Option<&dyn SourceCode>
fn source_code(&self) -> Option<&dyn SourceCode>
Diagnostic
’s Diagnostic::labels
to.Diagnostic
s.Source§fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
fn diagnostic_source(&self) -> Option<&dyn Diagnostic>
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
Source§impl From<BuildError> for GlobError
impl From<BuildError> for GlobError
Source§fn from(error: BuildError) -> Self
fn from(error: BuildError) -> Self
Source§impl From<Infallible> for BuildError
impl From<Infallible> for BuildError
Source§fn from(_: Infallible) -> Self
fn from(_: Infallible) -> Self
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more