Skip to main content

ephemeris_documents/error/
ownership.rs

1//! Errors from ownership declarations.
2
3use crate::ownership::ManagedPath;
4
5/// Error returned while validating ownership declarations.
6#[derive(Debug, Clone, thiserror::Error)]
7pub enum OwnershipError {
8    /// An ownership path is empty.
9    #[error("ownership path is empty")]
10    PathEmpty,
11    /// An ownership path does not follow the path grammar.
12    #[error("invalid ownership path at byte {offset}: {kind}")]
13    PathSyntax {
14        /// Byte offset of the problem in the path text.
15        offset: usize,
16        /// What is wrong at that offset.
17        kind: PathSyntaxError,
18    },
19    /// Two ownership paths overlap.
20    #[error("ownership paths {first} and {second} overlap")]
21    PathOverlap {
22        /// The earlier path.
23        first: ManagedPath,
24        /// The later path.
25        second: ManagedPath,
26    },
27}
28
29/// What is wrong in the text of an ownership path.
30#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
31pub enum PathSyntaxError {
32    /// A quoted key has no closing quote.
33    #[error("quoted key is not closed")]
34    UnterminatedQuote,
35    /// A backslash is followed by something other than `"` or a backslash.
36    #[error("invalid escape in quoted key")]
37    InvalidEscape,
38    /// A key has no characters.
39    #[error("key is empty")]
40    EmptyKey,
41    /// A character that the grammar does not allow at this position.
42    #[error("unexpected character")]
43    UnexpectedCharacter,
44}