aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xixanta/src/errors.rs')
-rw-r--r--lib/xixanta/src/errors.rs25
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)
+ }
+}