pub struct MechError {
pub program_range: Option<SourceRange>,
pub annotations: Vec<SourceRange>,
pub tokens: Vec<Token>,
pub compiler_location: Option<CompilerSourceRange>,
pub source: Option<Box<MechError>>,
pub message: Option<String>,
/* private fields */
}Fields§
§program_range: Option<SourceRange>§annotations: Vec<SourceRange>§tokens: Vec<Token>§compiler_location: Option<CompilerSourceRange>§source: Option<Box<MechError>>§message: Option<String>Implementations§
Source§impl MechError
impl MechError
pub fn new<K>(kind: K, message: Option<String>) -> MechErrorwhere
K: MechErrorKind2 + 'static,
Sourcepub fn kind_as<K>(&self) -> Option<&K>where
K: MechErrorKind2 + 'static,
pub fn kind_as<K>(&self) -> Option<&K>where
K: MechErrorKind2 + 'static,
Get the kind as a specific type, if it matches
Sourcepub fn kind_message(&self) -> String
pub fn kind_message(&self) -> String
Get the runtime message (delegates to the underlying kind)
Sourcepub fn display_message(&self) -> String
pub fn display_message(&self) -> String
Optional helper that returns the message or the explicit message override
Sourcepub fn kind_downcast_ref<K>(&self) -> Option<&K>where
K: 'static,
pub fn kind_downcast_ref<K>(&self) -> Option<&K>where
K: 'static,
If you ever need downcast access to the concrete kind:
Sourcepub fn with_compiler_loc(self) -> MechError
pub fn with_compiler_loc(self) -> MechError
Add a compiler location annotation with the current location
Sourcepub fn with_specific_compiler_loc(self, loc: CompilerSourceRange) -> MechError
pub fn with_specific_compiler_loc(self, loc: CompilerSourceRange) -> MechError
Specify a particular compiler location
Sourcepub fn with_annotation(self, range: SourceRange) -> MechError
pub fn with_annotation(self, range: SourceRange) -> MechError
Add a source range annotation
Sourcepub fn with_annotations<I>(self, iter: I) -> MechErrorwhere
I: IntoIterator<Item = SourceRange>,
pub fn with_annotations<I>(self, iter: I) -> MechErrorwhere
I: IntoIterator<Item = SourceRange>,
Add multiple source range annotations
Sourcepub fn with_tokens<I>(self, iter: I) -> MechErrorwhere
I: IntoIterator<Item = Token>,
pub fn with_tokens<I>(self, iter: I) -> MechErrorwhere
I: IntoIterator<Item = Token>,
Add tokens related to this error
Sourcepub fn with_source(self, src: MechError) -> MechError
pub fn with_source(self, src: MechError) -> MechError
Set the source error that caused this one
Sourcepub fn primary_range(&self) -> Option<SourceRange>
pub fn primary_range(&self) -> Option<SourceRange>
Get the primary source range associated with this error
Sourcepub fn simple_message(&self) -> String
pub fn simple_message(&self) -> String
Get a simple message describing the error
Sourcepub fn full_chain_message(&self) -> String
pub fn full_chain_message(&self) -> String
Get a full chain message including all source errors
pub fn boxed(self) -> Box<MechError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MechError
impl !RefUnwindSafe for MechError
impl Send for MechError
impl Sync for MechError
impl Unpin for MechError
impl UnsafeUnpin for MechError
impl !UnwindSafe for MechError
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.