From cf9b252bda551ea0464c5ceaec6a7dc13103b414 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Thu, 29 Jan 2026 15:15:42 +0000 Subject: [PATCH] Add source files: main, lib, cli, error, convert, highlight, validate, typescript --- src/error.rs | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 src/error.rs diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..6e47893 --- /dev/null +++ b/src/error.rs @@ -0,0 +1,77 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum ConfigForgeError { + #[error("Unsupported format '{format}'. Supported formats: json, yaml, toml, env, ini")] + UnsupportedFormat { format: String }, + + #[error("File '{path}' not found")] + FileNotFound { path: String }, + + #[error("Failed to parse {format} file: {details}")] + ParseError { format: String, details: String }, + + #[error("Validation failed at {path}: {reason}")] + ValidationError { path: String, reason: String }, + + #[error("Invalid JSON Schema: {details}")] + SchemaParseError { details: String }, + + #[error("IO error: {details}")] + IoError { details: String }, + + #[error("Conversion error: {details}")] + ConversionError { details: String }, + + #[error("Schema inference error: {details}")] + SchemaInferenceError { details: String }, + + #[error("TypeScript generation error: {details}")] + TypeScriptError { details: String }, +} + +impl From for ConfigForgeError { + fn from(e: std::io::Error) -> Self { + ConfigForgeError::IoError { + details: e.to_string(), + } + } +} + +impl From for ConfigForgeError { + fn from(e: serde_json::Error) -> Self { + ConfigForgeError::ParseError { + format: "JSON".to_string(), + details: e.to_string(), + } + } +} + +impl From for ConfigForgeError { + fn from(e: serde_yaml::Error) -> Self { + ConfigForgeError::ParseError { + format: "YAML".to_string(), + details: e.to_string(), + } + } +} + +impl From for ConfigForgeError { + fn from(e: toml::Error) -> Self { + ConfigForgeError::ParseError { + format: "TOML".to_string(), + details: e.to_string(), + } + } +} + +impl From for ConfigForgeError { + fn from(e: ini::Error) -> Self { + ConfigForgeError::ParseError { + format: "INI".to_string(), + details: e.to_string(), + } + } +} + +pub type Result = std::result::Result;