diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-20 13:04:39 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2024-12-20 13:06:40 +0100 |
| commit | 19e4da9fd654886f1a49dfb3509daa6526401774 (patch) | |
| tree | d2dfa3cbd7b5e2a10effdb8d15aa5fbf5c4d29c0 /lib/xixanta/src/errors.rs | |
| parent | 55d3c50c5dadbb4964781e3bf3c55b871eebd2b5 (diff) | |
| download | tools.nes-19e4da9fd654886f1a49dfb3509daa6526401774.tar.gz tools.nes-19e4da9fd654886f1a49dfb3509daa6526401774.zip | |
Improve the format of error messages
It was weird to show warnings which also showed "Error: " as a message,
and likewise it was weird for errors to display their kind, since users
simply do not care about this kind of information.
Hence, streamline the format to something closer to what it's done by
modern assemblers/compilers.
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 | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/xixanta/src/errors.rs b/lib/xixanta/src/errors.rs index f6317d4..63f925e 100644 --- a/lib/xixanta/src/errors.rs +++ b/lib/xixanta/src/errors.rs @@ -27,7 +27,7 @@ impl std::error::Error for ParseError {} impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "parser (line {}): {}.", self.line + 1, self.message) + write!(f, "{} (line {})", self.message, self.line + 1) } } @@ -54,14 +54,9 @@ impl std::error::Error for ContextError {} impl fmt::Display for ContextError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.global { - write!(f, "Context error: {}.", self.message) + write!(f, "{}", self.message) } else { - write!( - f, - "Context error (line {}): {}.", - self.line + 1, - self.message - ) + write!(f, "{} (line {})", self.message, self.line + 1) } } } @@ -88,14 +83,9 @@ impl From<ContextError> for EvalError { impl fmt::Display for EvalError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if self.global { - write!(f, "Evaluation error: {}.", self.message) + write!(f, "{}", self.message) } else { - write!( - f, - "Evaluation error (line {}): {}.", - self.line + 1, - self.message - ) + write!(f, "{} (line {})", self.message, self.line + 1) } } } |
