diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-10 16:55:26 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-10 16:55:26 +0100 |
| commit | 6d94077778d6043e135640f40b09e2582d3a3064 (patch) | |
| tree | 871bffa3f6b9e061f9af5f620a8d432139a3f310 /src/error.rs | |
| parent | d61370656d9f3deb39bb37f9c1d45e8ddc62efd5 (diff) | |
| download | sylt-6d94077778d6043e135640f40b09e2582d3a3064.tar.gz | |
Fix this shit
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/error.rs b/src/error.rs index 277be5f..22e0d1a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,15 +1,16 @@ use std::fmt; use std::path::PathBuf; use crate::vm::{Op, Value}; +use crate::tokenizer::Token; -#[derive(Debug)] +#[derive(Debug, Clone)] pub enum ErrorKind { TypeError(Op, Vec<Value>), AssertFailed(Value, Value), - SyntaxError(usize), + SyntaxError(usize, Token), } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Error { pub kind: ErrorKind, pub file: PathBuf, @@ -29,8 +30,8 @@ impl fmt::Display for ErrorKind { ErrorKind::AssertFailed(a, b) => { write!(f, "Assertion failed, {:?} != {:?}.", a, b) } - ErrorKind::SyntaxError(line) => { - write!(f, "Syntax error on line {}", line) + ErrorKind::SyntaxError(line, token) => { + write!(f, "Syntax error on line {} at token {:?}", line, token) } } } |
