diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-10 18:15:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-10 18:15:27 +0100 |
| commit | 21b76633d149f62dbfdf55702dbdf8c84bf14105 (patch) | |
| tree | 4de4557fff6785e4527e9df206f909d96a930028 /src/error.rs | |
| parent | e930f7b71ba526f40210f3e89afc79b2288e2e91 (diff) | |
| parent | 035ac6f1a0fde887ccbdfb9358adddcb89a5bae3 (diff) | |
| download | sylt-21b76633d149f62dbfdf55702dbdf8c84bf14105.tar.gz | |
Merge pull request #109 from FredTheDino/minor
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/error.rs b/src/error.rs index 9aca985..f967685 100644 --- a/src/error.rs +++ b/src/error.rs @@ -34,6 +34,9 @@ pub enum ErrorKind { SyntaxError(usize, Token), /// (start, end) GitConflictError(usize, usize), + + FileNotFound(PathBuf), + NoFileGiven, } #[derive(Debug, Clone)] @@ -54,10 +57,10 @@ impl fmt::Display for ErrorKind { write!(f, "Cannot apply {:?} to types {}", op, types) } ErrorKind::TypeMismatch(a, b) => { - write!(f, "Expected '{:?}' and got '{:?}'.", a, b) + write!(f, "Expected '{:?}' and got '{:?}'", a, b) } ErrorKind::CannotInfer(a, b) => { - write!(f, "Failed to infer type '{:?}' from '{:?}'.", a, b) + write!(f, "Failed to infer type '{:?}' from '{:?}'", a, b) } ErrorKind::ArgumentType(a, b) => { let expected = a @@ -70,7 +73,7 @@ impl fmt::Display for ErrorKind { expected, given) } ErrorKind::IndexError(value, slot) => { - write!(f, "Cannot index value '{:?}' with type '{:?}'.", value, slot) + write!(f, "Cannot index value '{:?}' with type '{:?}'", value, slot) } ErrorKind::ExternTypeMismatch(name, types) => { write!(f, "Extern function '{}' doesn't accept argument(s) with type(s) {:?}", @@ -86,7 +89,7 @@ impl fmt::Display for ErrorKind { write!(f, "Cannot find field '{}' on {:?}", field, obj) } ErrorKind::ArgumentCount(expected, given) => { - write!(f, "Incorrect argument count, expected {} but got {}.", + write!(f, "Incorrect argument count, expected {} but got {}", expected, given) } ErrorKind::IndexOutOfBounds(value, len, slot) => { @@ -100,7 +103,7 @@ impl fmt::Display for ErrorKind { write!(f, "{}", "[!!] Invalid program [!!]".bold()) } ErrorKind::Unreachable => { - write!(f, "Reached unreachable code.") + write!(f, "Reached unreachable code") } ErrorKind::SyntaxError(line, token) => { write!(f, "Syntax Error on line {} at token {:?}", line, token) @@ -109,6 +112,12 @@ impl fmt::Display for ErrorKind { write!(f, "Git conflict markers found between lines {} and {}", start_line, end_line) } + ErrorKind::FileNotFound(path) => { + write!(f, "File '{}' not found", path.display()) + } + ErrorKind::NoFileGiven => { + write!(f, "No file to run") + } } } } |
