Struct wax::BuildError
source · pub struct BuildError { /* private fields */ }
Expand description
Describes errors that occur when building a Program
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.