From c9627417191f2ef1eea50ed56c26f12d7a9081be Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Tue, 17 Aug 2021 22:07:07 -0400 Subject: [PATCH] Add byte a offset to the error message --- saphyr/src/scanner.rs | 5 +++-- saphyr/tests/basic.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/saphyr/src/scanner.rs b/saphyr/src/scanner.rs index 24a33dd..dff285b 100644 --- a/saphyr/src/scanner.rs +++ b/saphyr/src/scanner.rs @@ -108,10 +108,11 @@ impl fmt::Display for ScanError { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { write!( formatter, - "{} at line {} column {}", + "{} at byte {} line {} column {}", self.info, + self.mark.index, self.mark.line, - self.mark.col + 1 + self.mark.col + 1, ) } } diff --git a/saphyr/tests/basic.rs b/saphyr/tests/basic.rs index e516cd6..b769c2b 100644 --- a/saphyr/tests/basic.rs +++ b/saphyr/tests/basic.rs @@ -61,7 +61,7 @@ key1:a2 ); assert_eq!( error.to_string(), - "mapping values are not allowed in this context at line 4 column 4" + "mapping values are not allowed in this context at byte 26 line 4 column 4" ); }