diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-05-17 07:39:05 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-12 07:30:15 +0100 |
| commit | 587dd5bb80364688419bb43aba4afc044ac0ef48 (patch) | |
| tree | 3f79940572c4b5ff7fab38e9d3a92a908afc8907 /lib/xixanta/src/errors.rs | |
| download | tools.nes-587dd5bb8036.tar.gz tools.nes-587dd5bb8036.zip | |
Initial commit
A lot is missing and there is a long road ahead to make the assembler
even work.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src/errors.rs')
| -rw-r--r-- | lib/xixanta/src/errors.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/xixanta/src/errors.rs b/lib/xixanta/src/errors.rs new file mode 100644 index 0000000..48f7286 --- /dev/null +++ b/lib/xixanta/src/errors.rs @@ -0,0 +1,25 @@ +use std::fmt; + +#[derive(Debug, Clone, PartialEq)] +pub struct ParseError { + pub line: usize, + pub message: String, +} + +impl std::error::Error for ParseError {} + +impl From<std::io::Error> for ParseError { + fn from(err: std::io::Error) -> Self { + // TODO + ParseError { + line: 0, + message: err.to_string(), + } + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "parser (line {}): {}.", self.line + 1, self.message) + } +} |
