Jelajahi Sumber

Make error messages easier to read

Before:
```
Error: Parsing label command in comment failed: ...ify labels|error: must have : or to as label starter at >| A-diagnos...
```

After:
```
Error: Parsing label command in comment failed: ...'ify labels' | error: must have `:` or `to` as label starter at >| ' A-diagnos'...
```
Joshua Nelson 5 tahun lalu
induk
melakukan
8a0913cd4a
2 mengubah file dengan 3 tambahan dan 3 penghapusan
  1. 2 2
      parser/src/command/relabel.rs
  2. 1 1
      parser/src/error.rs

+ 2 - 2
parser/src/command/relabel.rs

@@ -56,8 +56,8 @@ impl fmt::Display for ParseError {
         match self {
             ParseError::EmptyLabel => write!(f, "empty label"),
             ParseError::ExpectedLabelDelta => write!(f, "a label delta"),
-            ParseError::MisleadingTo => write!(f, "forbidden to, use +to"),
-            ParseError::NoSeparator => write!(f, "must have : or to as label starter"),
+            ParseError::MisleadingTo => write!(f, "forbidden `to`, use `+to`"),
+            ParseError::NoSeparator => write!(f, "must have `:` or `to` as label starter"),
         }
     }
 }

+ 1 - 1
parser/src/error.rs

@@ -32,7 +32,7 @@ impl<'a> fmt::Display for Error<'a> {
         let end = std::cmp::min(self.input.len(), self.position + space);
         write!(
             f,
-            "...{}|error: {} at >|{}...",
+            "...'{}' | error: {} at >| '{}'...",
             &self.input[self.position.saturating_sub(space)..self.position],
             self.source,
             &self.input[self.position..end],