KeiSeiKit-1.0/_primitives/_rust/kei-atom-discovery/src/error.rs
Parfii-bot a4e667de10 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

47 lines
1.3 KiB
Rust

//! Typed errors for atom discovery + frontmatter parsing.
//!
//! Every failure mode is a distinct variant — callers pattern-match by variant,
//! not by `to_string()` scraping.
use std::path::PathBuf;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("path escape: `{rel}` escapes base `{}`", base.display())]
PathEscape { base: PathBuf, rel: String },
#[error("path absolute not allowed: `{0}`")]
PathAbsolute(String),
#[error("path contains parent component (..): `{0}`")]
PathParent(String),
#[error("canonicalize `{}`: {source}", path.display())]
Canonicalize {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("frontmatter missing leading --- delimiter")]
FrontmatterMissingStart,
#[error("frontmatter missing closing --- delimiter")]
FrontmatterMissingEnd,
#[error("frontmatter exceeds {limit} bytes (got {got})")]
FrontmatterTooLarge { limit: usize, got: usize },
#[error("yaml parse: {0}")]
Yaml(#[from] serde_yaml_ng::Error),
#[error("atom id must be `<crate>::<verb>`, got `{0}`")]
BadAtomId(String),
#[error("unknown atom kind: `{0}`")]
UnknownKind(String),
#[error("io: {0}")]
Io(#[from] std::io::Error),
}