Skip to content

Commit

Permalink
feat: implement Display + Debug for UmError
Browse files Browse the repository at this point in the history
  • Loading branch information
nfejzic committed Nov 18, 2021
1 parent 71ac7c8 commit bd3fd09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/frontend/syntax_error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::fmt::Display;
use std::fmt;

use unicode_segmentation::UnicodeSegmentation;

use super::parser::CursorPos;

#[derive(Debug)]
pub struct SyntaxError {
pub start_pos: CursorPos,
pub current_pos: CursorPos,
Expand Down Expand Up @@ -51,7 +52,7 @@ impl SyntaxError {
}
}

impl Display for SyntaxError {
impl fmt::Display for SyntaxError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let start_line_number = self.start_pos.line;
let start_symbol = self.start_pos.symbol;
Expand Down
9 changes: 9 additions & 0 deletions src/um_error/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ impl fmt::Display for UmError {
}
}
}

impl fmt::Debug for UmError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
UmError::Syntax(err) => err.fmt(f),
UmError::Ir(err) => err.fmt(f),
}
}
}

0 comments on commit bd3fd09

Please sign in to comment.