Skip to content

Commit

Permalink
feat(astgen): add Disply trait to AstGenError
Browse files Browse the repository at this point in the history
  • Loading branch information
SkuldNorniern committed Feb 5, 2024
1 parent 7809214 commit 61744f2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nk-astgen/src/parser_new/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ pub struct AstGenError {
//pub line: usize,
//pub column: usize,
pub message: AstError,
pub pretty_display: String,
}
impl AstGenError {
pub fn new(message: AstError) -> Self {
AstGenError {
message,
pretty_display: "".to_string(),
}
}
}
impl fmt::Display for AstGenError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "AST Gen Error: {}", self.message)
write!(f, "Error: {}", self.message)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
Expand All @@ -29,8 +38,8 @@ impl fmt::Display for AstError {
match self {
AstError::ExpectedToken(t) => write!(
f,
"Expected token: {} on line: {} column: {}",
t.token_type, t.metadata.line, t.metadata.column
"Expected token: {} ",
t.token_type
),
AstError::ExpectedStatement() => write!(f, "Expected statement"),
AstError::ExpectedExpression() => write!(f, "Expected expression"),
Expand Down

0 comments on commit 61744f2

Please sign in to comment.