-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors.rs
More file actions
47 lines (41 loc) · 1.61 KB
/
errors.rs
File metadata and controls
47 lines (41 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Unified Create Command Errors
//!
//! This module defines a unified error type that encompasses all create subcommand errors,
//! providing a single interface for environment, template, schema, and CLI schema command errors.
use thiserror::Error;
use super::subcommands::{
environment::CreateEnvironmentCommandError, schema::CreateSchemaCommandError,
template::CreateEnvironmentTemplateCommandError,
};
/// Unified error type for all create subcommands
///
/// This error type provides a unified interface for errors that can occur during
/// any create subcommand execution (environment creation, template generation,
/// or schema generation).
/// It wraps the specific command errors while preserving their context and help methods.
#[derive(Debug, Error)]
pub enum CreateCommandError {
/// Environment creation errors
#[error(transparent)]
Environment(#[from] CreateEnvironmentCommandError),
/// Template generation errors
#[error(transparent)]
Template(#[from] CreateEnvironmentTemplateCommandError),
/// Schema generation errors
#[error(transparent)]
Schema(#[from] CreateSchemaCommandError),
}
impl CreateCommandError {
/// Get detailed troubleshooting guidance for this error
///
/// This method delegates to the specific command error's help method,
/// providing context-appropriate troubleshooting guidance.
#[must_use]
pub fn help(&self) -> String {
match self {
Self::Environment(err) => err.help().to_string(),
Self::Template(err) => err.help().to_string(),
Self::Schema(err) => err.help(),
}
}
}