1use thiserror::Error;
2
3fn display_content(content: &str) -> String {
4 if content.is_empty() {
5 String::new()
6 } else {
7 format!(" after {content}")
8 }
9}
10
11#[derive(Debug, Error, PartialEq)]
16#[non_exhaustive]
17pub enum JqlParserError {
18 #[error("Empty input")]
20 EmptyInputError,
21
22 #[error("Unable to parse input {unparsed}{}", display_content(tokens))]
24 ParsingError {
25 tokens: String,
27 unparsed: String,
29 },
30
31 #[error("Truncate operator found as non last element or multiple times in {0}")]
33 TruncateError(String),
34
35 #[error("Unknown error")]
37 UnknownError,
38}
39
40#[cfg(test)]
41mod tests {
42
43 use super::display_content;
44
45 #[test]
46 fn check_display_content() {
47 assert_eq!(display_content("some"), " after some");
48 assert_eq!(display_content(""), "");
49 }
50}