1use super::{indent, parse::PestError};
2
3#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7 #[error("Parse error: {0}")]
9 PestError(#[from] PestError),
10
11 #[error("Integer parse error: {0}")]
13 ParseIntError(#[from] std::num::ParseIntError),
14
15 #[error("Float parse error: {0}")]
17 ParseFloatError(#[from] std::num::ParseFloatError),
18
19 #[error("Base64 decode error: {0}")]
21 Base64DecodeError(#[from] base64::DecodeError),
22
23 #[error("Invalid escape character: {0}")]
25 InvalidEscapeChar(char),
26
27 #[error("Invalid unicode escape: {0}")]
29 InvalidUnicodeEscape(String),
30
31 #[error("Invalid unicode codepoint: {0}")]
33 InvalidUnicodeCodepoint(u32),
34
35 #[error("Hex binary must have even number of digits")]
37 OddHexDigits,
38
39 #[error("Duplicate key in map: {0}")]
41 DuplicateKey(String),
42
43 #[error("Invalid timestamp '{0}': {1}")]
45 InvalidTimestamp(String, String),
46
47 #[error("Mixed tabs and spaces in indentation, got '{0:?}'")]
49 MixedIndent(String),
50
51 #[error("Inconsistent indent char: expected '{0}', got '{1}'")]
53 InconsistentIndentTab(indent::Tab, indent::Tab),
54
55 #[error("Invalid indentation: expected multiple of {0}, got {1}")]
57 InvalidIndentCount(usize, usize),
58
59 #[error("Unexpected indentation: expected {0}, got {1}")]
61 UnexpectedIndent(usize, usize),
62
63 #[error("Empty document")]
65 EmptyDocument,
66
67 #[error("Missing value at line {0}")]
69 MissingValue(usize),
70}
71
72pub type Result<T> = std::result::Result<T, Error>;