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)]
13pub enum JqlParserError {
14 #[error("Empty input")]
16 EmptyInputError,
17
18 #[error("Unable to parse input {unparsed}{}", display_content(tokens))]
20 ParsingError {
21 tokens: String,
23 unparsed: String,
25 },
26
27 #[error("Truncate operator found as non last element or multiple times in {0}")]
29 TruncateError(String),
30
31 #[error("Unknown error")]
33 UnknownError,
34}
35
36#[cfg(test)]
37mod tests {
38
39 use super::display_content;
40
41 #[test]
42 fn check_display_content() {
43 assert_eq!(display_content("some"), " after some");
44 assert_eq!(display_content(""), "");
45 }
46}