Skip to main content

haz_query/expr/
atom.rs

1//! Atom-validation errors shared across the per-attribute
2//! lifters in [`super`].
3
4use haz_domain::name::NameError;
5use haz_domain::path::PathPatternError;
6use haz_query_lang::span::Span;
7use snafu::Snafu;
8
9/// Atom-validation failure produced while lifting a parsed atom
10/// to its typed representation. Each variant captures the
11/// offending byte span and the underlying validation error.
12#[derive(Debug, Clone, PartialEq, Eq, Snafu)]
13pub enum AtomError {
14    /// Violates `QRY-003` for `--tags`: the atom text is not a
15    /// valid `TagName` per `ID-001..ID-005`.
16    #[snafu(display("invalid tag name at {span}: {source}"))]
17    InvalidTagName {
18        /// Span of the offending atom in the original input.
19        span: Span,
20        /// Underlying identifier-rule violation.
21        source: NameError,
22    },
23
24    /// Violates `QRY-003` for `--projects`: the atom text is not
25    /// a valid `ProjectName` per `ID-001..ID-005`.
26    #[snafu(display("invalid project name at {span}: {source}"))]
27    InvalidProjectName {
28        /// Span of the offending atom in the original input.
29        span: Span,
30        /// Underlying identifier-rule violation.
31        source: NameError,
32    },
33
34    /// Violates `QRY-003` for `--tasks`: the atom text is not a
35    /// valid `TaskName` per `ID-001..ID-005`.
36    #[snafu(display("invalid task name at {span}: {source}"))]
37    InvalidTaskName {
38        /// Span of the offending atom in the original input.
39        span: Span,
40        /// Underlying identifier-rule violation.
41        source: NameError,
42    },
43
44    /// Violates `QRY-003` for `--inputs` / `--outputs`: the atom
45    /// text is not a valid path pattern per
46    /// `PATH-001..PATH-016`.
47    #[snafu(display("invalid path pattern at {span}: {source}"))]
48    InvalidPathPattern {
49        /// Span of the offending atom in the original input.
50        span: Span,
51        /// Underlying path-pattern-rule violation.
52        source: PathPatternError,
53    },
54
55    /// Violates `QRY-004`: the relational atom is missing the
56    /// `:` separator between the kind keyword and the value.
57    #[snafu(display("relational atom at {span} is missing the `:` separator"))]
58    MissingRelationalColon {
59        /// Span of the offending atom in the original input.
60        span: Span,
61    },
62
63    /// Violates `QRY-004`: the kind keyword of the relational
64    /// atom is not one of `name`, `project`, or `tag`
65    /// (case-sensitive).
66    #[snafu(display(
67        "unknown relational kind '{kind}' at {span}; expected one of name, project, tag"
68    ))]
69    UnknownRelationalKind {
70        /// Span of the offending atom in the original input.
71        span: Span,
72        /// The offending kind keyword as the user wrote it.
73        kind: String,
74    },
75}