1use crate::codes::UnknownCode;
9
10#[derive(Debug, thiserror::Error, PartialEq, Eq)]
11#[non_exhaustive]
12pub enum ParseError {
13 #[error("empty input")]
14 EmptyInput,
15
16 #[error("indent jumped from depth {from} to depth {to} on line {line}")]
17 IndentJump { from: usize, to: usize, line: usize },
18
19 #[error("malformed line {line}: {message}")]
20 MalformedLine { line: usize, message: &'static str },
21
22 #[error("invalid ref {raw:?}")]
23 InvalidRef { raw: String },
24
25 #[error("invalid position {raw:?}")]
26 InvalidPosition { raw: String },
27
28 #[error("missing field: {field}")]
29 MissingField { field: &'static str },
30
31 #[error("unknown code: {0}")]
32 UnknownCode(#[from] UnknownCode),
33
34 #[error("invalid envelope: {detail}")]
35 InvalidEnvelope { detail: &'static str },
36
37 #[error("invalid state token {raw:?}: expected 16 lowercase hex chars")]
38 InvalidToken { raw: String },
39
40 #[error("invalid attribute {raw:?}")]
41 InvalidAttribute { raw: String },
42
43 #[error("invalid request: {detail}")]
44 InvalidRequest { detail: &'static str },
45
46 #[error("invalid label {raw:?}: contains an unterminated quoted span")]
47 UnterminatedQuote { raw: String },
48
49 #[error("delta apply: ref {0} not present in source tree")]
50 ApplyMissingRef(u32),
51
52 #[error("delta apply: ref {0} already exists in source tree")]
53 ApplyDuplicateRef(u32),
54
55 #[error("delta apply: parent ref {0} not present")]
56 ApplyMissingParent(u32),
57}
58
59pub type Result<T> = std::result::Result<T, ParseError>;