Skip to main content

ephemeris_documents/error/
yaml.rs

1//! Errors from reading YAML source.
2
3use crate::path::KeyPath;
4
5/// Error returned while reading a YAML source tree.
6#[derive(Debug, thiserror::Error)]
7pub enum YamlError {
8    /// `yaml-rt` failed to parse the source.
9    #[error("invalid YAML")]
10    Parse {
11        /// The underlying parse error.
12        #[source]
13        source: Box<yaml_rt::YamlError>,
14    },
15    /// The source holds more than one YAML document.
16    #[error("YAML source holds {count} documents, but only one is supported")]
17    MultipleDocuments {
18        /// The number of documents in the source.
19        count: usize,
20    },
21    /// A mapping that the merge has to enter is written in a layout the
22    /// editor cannot change, such as a flow mapping with entries, explicit
23    /// keys, or mixed indentation.
24    #[error("YAML layout at `{path}` is unsupported")]
25    UnsupportedLayout {
26        /// The key path of the mapping.
27        path: KeyPath,
28    },
29    /// A block mapping holds the same key twice.
30    #[error("YAML mapping at `{path}` holds the key `{key}` more than once")]
31    DuplicateKey {
32        /// The key path of the mapping that holds the key.
33        path: KeyPath,
34        /// The repeated key.
35        key: String,
36    },
37}