openapi_nexus_go/
errors.rs1use snafu::Snafu;
4
5#[derive(Debug, Snafu)]
7#[snafu(visibility(pub))]
8pub enum GeneratorError {
9 #[snafu(display("Failed to render template '{}': {}", template_path, source))]
11 TemplateRender {
12 template_path: String,
13 source: minijinja::Error,
14 },
15
16 #[snafu(display("Template '{}' not found: {}", template_path, source))]
18 TemplateNotFound {
19 template_path: String,
20 source: minijinja::Error,
21 },
22
23 #[snafu(display("Failed to generate API client '{}': {}", client_name, source))]
25 ApiClientGeneration {
26 client_name: String,
27 source: Box<dyn std::error::Error + Send + Sync>,
28 },
29
30 #[snafu(display("Failed to generate model '{}': {}", model_name, source))]
32 ModelGeneration {
33 model_name: String,
34 source: Box<dyn std::error::Error + Send + Sync>,
35 },
36
37 #[snafu(display("Failed to map type: {}", source))]
39 TypeMapping {
40 source: Box<dyn std::error::Error + Send + Sync>,
41 },
42
43 #[snafu(display("File I/O error: {}", source))]
45 Io { source: std::io::Error },
46
47 #[snafu(display("Failed to parse config: {}", source))]
49 ConfigParse { source: toml::de::Error },
50
51 #[snafu(display("Generator error: {}", message))]
53 Generic { message: String },
54}
55
56impl From<std::io::Error> for GeneratorError {
57 fn from(err: std::io::Error) -> Self {
58 GeneratorError::Io { source: err }
59 }
60}
61
62impl From<toml::de::Error> for GeneratorError {
63 fn from(err: toml::de::Error) -> Self {
64 GeneratorError::ConfigParse { source: err }
65 }
66}
67
68impl From<Box<dyn std::error::Error + Send + Sync>> for GeneratorError {
69 fn from(err: Box<dyn std::error::Error + Send + Sync>) -> Self {
70 GeneratorError::Generic {
71 message: err.to_string(),
72 }
73 }
74}