Skip to main content

codex_patcher/toml/
errors.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum TomlError {
6    #[error("invalid TOML syntax: {message}")]
7    InvalidTomlSyntax { message: String },
8
9    #[error("invalid section path '{input}': {message}")]
10    InvalidSectionPath { input: String, message: String },
11
12    #[error("section not found: {path}")]
13    SectionNotFound { path: String },
14
15    #[error("key not found: {section}.{key}")]
16    KeyNotFound { section: String, key: String },
17
18    #[error("ambiguous match for {kind}: {path}")]
19    AmbiguousMatch { kind: String, path: String },
20
21    #[error("invalid positioning: {message}")]
22    InvalidPositioning { message: String },
23
24    #[error("unsupported TOML construct: {message}")]
25    Unsupported { message: String },
26
27    #[error("toml edit would be a no-op: {reason}")]
28    NoOp { reason: String },
29
30    #[error("I/O error: {0}")]
31    Io(#[from] std::io::Error),
32
33    #[error("edit error: {0}")]
34    Edit(#[from] crate::edit::EditError),
35
36    #[error("invalid path: {0}")]
37    InvalidPath(PathBuf),
38}