1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use core::fmt;
use std::error::Error;
#[derive(Debug, PartialEq, Clone)]
#[non_exhaustive]
#[allow(dead_code)]
#[doc(hidden)]
#[allow(clippy::enum_variant_names)]
pub(crate) enum MiniYamlError {
AliasesDisallowed,
AnchorsDisallowed,
TagsDisallowed,
}
#[derive(Debug, PartialEq, Clone)]
pub struct YamlParseError {
pub(crate) line: usize,
pub(crate) col: usize,
pub(crate) msg: Option<String>,
pub(crate) source: Option<MiniYamlError>,
}
impl Error for YamlParseError {}
impl fmt::Display for YamlParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.msg {
Some(ref msg) => write!(
f,
"error occurred parsing the input at line {}, column {} : {}",
self.line, self.col, msg
),
None => write!(
f,
"error occurred parsing the input at line {}, column {}",
self.line, self.col
),
}
}
}
impl Error for MiniYamlError {}
impl fmt::Display for MiniYamlError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
MiniYamlError::AliasesDisallowed => "aliases are disallowed in minimal-yaml",
MiniYamlError::AnchorsDisallowed => "anchors are disallowed in minimal-yaml",
MiniYamlError::TagsDisallowed => "tags are disallowed in minimal-yaml",
}
)
}
}