Files
komodo/lib/config/src/error.rs
T
2025-08-08 22:33:21 -07:00

63 lines
1.8 KiB
Rust

use std::path::PathBuf;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(
"Types on field {key} do not match | got {value:?}, expected object"
)]
ObjectFieldTypeMismatch {
key: String,
value: Box<dyn std::fmt::Debug>,
},
#[error(
"Types on field {key} do not match | got {value:?}, expected array"
)]
ArrayFieldTypeMismatch {
key: String,
value: Box<dyn std::fmt::Debug>,
},
#[error("Failed to open file at {path} | {e:?}")]
FileOpen { e: std::io::Error, path: PathBuf },
#[error("Failed to read contents of file at {path} | {e:?}")]
ReadFileContents { e: std::io::Error, path: PathBuf },
#[error("Failed to parse toml file at {path} | {e:?}")]
ParseToml { e: toml::de::Error, path: PathBuf },
#[error("Failed to parse yaml file at {path} | {e:?}")]
ParseYaml {
e: serde_yaml_ng::Error,
path: PathBuf,
},
#[error("Failed to parse json file at {path} | {e:?}")]
ParseJson { e: serde_json::Error, path: PathBuf },
#[error("Unsupported file type at {path}")]
UnsupportedFileType { path: PathBuf },
#[error("Failed to parse merged config into final type | {e:?}")]
ParseFinalJson { e: serde_json::Error },
#[error("Failed to serialize merged config to string | {e:?}")]
SerializeFinalJson { e: serde_json::Error },
#[error("Failed to read directory at {path:?}")]
ReadDir { path: PathBuf, e: std::io::Error },
#[error("Failed to get file handle for file in directory {path:?}")]
DirFile { e: std::io::Error, path: PathBuf },
#[error("Failed to get file name for file at {path:?}")]
GetFileName { path: PathBuf },
#[error("Failed to get metadata for path {path:?} | {e:?}")]
ReadPathMetaData { path: PathBuf, e: std::io::Error },
#[error("Parsed value is not object")]
ValueIsNotObject,
}