Skip to main content

rdbi_codegen/
error.rs

1//! Error types for rdbi-codegen
2
3use thiserror::Error;
4
5/// Result type alias for rdbi-codegen operations
6pub type Result<T> = std::result::Result<T, CodegenError>;
7
8/// Errors that can occur during code generation
9#[derive(Error, Debug)]
10pub enum CodegenError {
11    #[error("Failed to parse SQL schema: {0}")]
12    ParseError(String),
13
14    #[error("Configuration error: {0}")]
15    ConfigError(String),
16
17    #[error("Validation error: {0}")]
18    ValidationError(String),
19
20    #[error("IO error: {0}")]
21    IoError(#[from] std::io::Error),
22
23    #[error("Invalid table name: {0}")]
24    InvalidTableName(String),
25
26    #[error("Unsupported data type: {0}")]
27    UnsupportedDataType(String),
28}
29
30impl From<sqlparser::parser::ParserError> for CodegenError {
31    fn from(err: sqlparser::parser::ParserError) -> Self {
32        CodegenError::ParseError(err.to_string())
33    }
34}
35
36impl From<config::ConfigError> for CodegenError {
37    fn from(err: config::ConfigError) -> Self {
38        CodegenError::ConfigError(err.to_string())
39    }
40}