-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69456a7
commit 2264715
Showing
5 changed files
with
556 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use std::fmt; | ||
|
||
#[derive(Debug)] | ||
pub enum Error { | ||
SyntaxError(String), | ||
IndexOutOfBounds(String), | ||
VariableNotDeclared(String), | ||
VariableAlreadyDeclared(String), | ||
TypeError(String), | ||
UnsupportedOperation(String), | ||
BreakOutsideLoop, | ||
ContinueOutsideLoop, | ||
//UnknownError(String), | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match self { | ||
Error::SyntaxError(msg) => write!(f, "SyntaxError: {}", msg), | ||
Error::IndexOutOfBounds(msg) => write!(f, "IndexOutOfBounds: {}", msg), | ||
Error::VariableNotDeclared(msg) => write!(f, "VariableNotDeclared: {}", msg), | ||
Error::VariableAlreadyDeclared(msg) => write!(f, "VariableAlreadyDeclared: {}", msg), | ||
Error::TypeError(msg) => write!(f, "TypeError: {}", msg), | ||
Error::UnsupportedOperation(msg) => write!(f, "UnsupportedOperation: {}", msg), | ||
Error::BreakOutsideLoop => write!(f, "Break statement outside of loop"), | ||
Error::ContinueOutsideLoop => write!(f, "Continue statement outside of loop"), | ||
// Error::UnknownError(msg) => write!(f, "UnknownError: {}", msg), | ||
} | ||
} | ||
} | ||
|
||
impl std::error::Error for Error {} |
Oops, something went wrong.