pub enum CompilerError {
SyntaxError {
position: ErrorPosition,
message: String,
code: String,
expected: Rule,
found: Option<Rule>,
},
FileRuleError {
error: Box<Error<Rule>>,
},
}
Variants§
SyntaxError
A generic syntax error
Fields
§
position: ErrorPosition
FileRuleError
An error when parsing the file rule
Implementations§
Source§impl CompilerError
impl CompilerError
Sourcepub fn log_error(&self)
pub fn log_error(&self)
Log the error to the console
with the format Syntax error At position {position}: {message} - Expected {expected:?}, got {found:?}
or Syntax error: {error}
if the error is a FileRuleError
Sourcepub fn get_message_expected(&self) -> String
pub fn get_message_expected(&self) -> String
Get the expected message. If the error is a FileRuleError
, the message will be extracted from pest::error::Error
, otherwise it will be Expected {expected:?}, got {found:?}
Sourcepub fn code(&self) -> String
pub fn code(&self) -> String
Get the code that caused the error. If the error is a FileRuleError
, the code will be extracted from pest::error::Error
Sourcepub fn line(&self) -> usize
pub fn line(&self) -> usize
Get the line of the error. If the error is a FileRuleError
, the line will be 0
Sourcepub fn position(&self) -> ErrorPosition
pub fn position(&self) -> ErrorPosition
Get the position of the error. It extracts the position from the pest::error::Error
if the error is a FileRuleError
Trait Implementations§
Source§impl Clone for CompilerError
impl Clone for CompilerError
Source§fn clone(&self) -> CompilerError
fn clone(&self) -> CompilerError
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for CompilerError
impl Debug for CompilerError
Source§impl PartialEq for CompilerError
impl PartialEq for CompilerError
impl Eq for CompilerError
impl StructuralPartialEq for CompilerError
Auto Trait Implementations§
impl Freeze for CompilerError
impl RefUnwindSafe for CompilerError
impl Send for CompilerError
impl Sync for CompilerError
impl Unpin for CompilerError
impl UnwindSafe for CompilerError
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