Skip to main content

CommandError

Enum CommandError 

Source
pub enum CommandError {
Show 16 variants Create(Box<CreateCommandError>), Destroy(Box<DestroySubcommandError>), Docs(Box<DocsCommandError>), Provision(Box<ProvisionSubcommandError>), Configure(Box<ConfigureSubcommandError>), Test(Box<TestSubcommandError>), Register(Box<RegisterSubcommandError>), Release(Box<ReleaseSubcommandError>), Render(Box<RenderCommandError>), Run(Box<RunSubcommandError>), Show(Box<ShowSubcommandError>), Exists(Box<ExistsSubcommandError>), List(Box<ListSubcommandError>), Purge(Box<PurgeSubcommandError>), Validate(Box<ValidateSubcommandError>), UserOutputLockFailed,
}
Expand description

Errors that can occur during CLI command execution

This enum provides a unified interface for all command-specific errors, following the project’s error handling conventions with structured error types, source preservation, and tiered help system support.

Variants§

§

Create(Box<CreateCommandError>)

Create command specific errors

Encapsulates all errors that can occur during create operations (environment or template). Use .help() for detailed troubleshooting steps.

§

Destroy(Box<DestroySubcommandError>)

Destroy command specific errors

Encapsulates all errors that can occur during environment destruction. Use .help() for detailed troubleshooting steps.

§

Docs(Box<DocsCommandError>)

Docs command specific errors

Encapsulates all errors that can occur during CLI documentation generation. Use .help() for detailed troubleshooting steps.

§

Provision(Box<ProvisionSubcommandError>)

Provision command specific errors

Encapsulates all errors that can occur during infrastructure provisioning. Use .help() for detailed troubleshooting steps.

§

Configure(Box<ConfigureSubcommandError>)

Configure command specific errors

Encapsulates all errors that can occur during environment configuration. Use .help() for detailed troubleshooting steps.

§

Test(Box<TestSubcommandError>)

Test command specific errors

Encapsulates all errors that can occur during infrastructure validation. Use .help() for detailed troubleshooting steps.

§

Register(Box<RegisterSubcommandError>)

Register command specific errors

Encapsulates all errors that can occur during instance registration. Use .help() for detailed troubleshooting steps.

§

Release(Box<ReleaseSubcommandError>)

Release command specific errors

Encapsulates all errors that can occur during software release operations. Use .help() for detailed troubleshooting steps.

§

Render(Box<RenderCommandError>)

Render command specific errors

Encapsulates all errors that can occur during artifact generation. Use .help() for detailed troubleshooting steps.

§

Run(Box<RunSubcommandError>)

Run command specific errors

Encapsulates all errors that can occur during stack execution. Use .help() for detailed troubleshooting steps.

§

Show(Box<ShowSubcommandError>)

Show command specific errors

Encapsulates all errors that can occur during environment information display. Use .help() for detailed troubleshooting steps.

§

Exists(Box<ExistsSubcommandError>)

Exists command specific errors

Encapsulates all errors that can occur during environment existence check. Use .help() for detailed troubleshooting steps.

§

List(Box<ListSubcommandError>)

List command specific errors

Encapsulates all errors that can occur during environment listing. Use .help() for detailed troubleshooting steps.

§

Purge(Box<PurgeSubcommandError>)

Purge command specific errors

Encapsulates all errors that can occur during local environment data removal. Use .help() for detailed troubleshooting steps.

§

Validate(Box<ValidateSubcommandError>)

Validate command specific errors

Encapsulates all errors that can occur during configuration validation. Use .help() for detailed troubleshooting steps.

§

UserOutputLockFailed

User output lock acquisition failed

Failed to acquire the mutex lock for user output. This typically indicates a panic occurred in another thread while holding the lock.

Implementations§

Source§

impl CommandError

Source

pub fn help(&self) -> String

Get detailed troubleshooting guidance for this error

This method provides comprehensive troubleshooting steps that can be displayed to users when they need more help resolving the error. It delegates to the specific command error’s help method.

§Example
use clap::Parser;
use torrust_tracker_deployer_lib::presentation::cli::errors;
use torrust_tracker_deployer_lib::presentation::cli::controllers::destroy::DestroySubcommandError;
use torrust_tracker_deployer_lib::application::command_handlers::destroy::DestroyCommandHandlerError;
use std::path::PathBuf;

// Create error for demonstration
let destroy_error = DestroySubcommandError::DestroyOperationFailed {
    name: "test-env".to_string(),
    source: DestroyCommandHandlerError::StateCleanupFailed {
        path: PathBuf::from("/tmp/test"),
        source: std::io::Error::new(std::io::ErrorKind::PermissionDenied, "access denied"),
    },
};
let error = errors::CommandError::Destroy(Box::new(destroy_error));

// Get help text
let help_text = error.help();
println!("{}", help_text);

Trait Implementations§

Source§

impl Debug for CommandError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CommandError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CommandError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ConfigureSubcommandError> for CommandError

Source§

fn from(error: ConfigureSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<CreateCommandError> for CommandError

Source§

fn from(error: CreateCommandError) -> Self

Converts to this type from the input type.
Source§

impl From<DestroySubcommandError> for CommandError

Source§

fn from(error: DestroySubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<DocsCommandError> for CommandError

Source§

fn from(error: DocsCommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ExistsSubcommandError> for CommandError

Source§

fn from(error: ExistsSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ListSubcommandError> for CommandError

Source§

fn from(error: ListSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ProvisionSubcommandError> for CommandError

Source§

fn from(error: ProvisionSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<PurgeSubcommandError> for CommandError

Source§

fn from(error: PurgeSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<RegisterSubcommandError> for CommandError

Source§

fn from(error: RegisterSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ReleaseSubcommandError> for CommandError

Source§

fn from(error: ReleaseSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<RenderCommandError> for CommandError

Source§

fn from(error: RenderCommandError) -> Self

Converts to this type from the input type.
Source§

impl From<RunSubcommandError> for CommandError

Source§

fn from(error: RunSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ShowSubcommandError> for CommandError

Source§

fn from(error: ShowSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<TestSubcommandError> for CommandError

Source§

fn from(error: TestSubcommandError) -> Self

Converts to this type from the input type.
Source§

impl From<ValidateSubcommandError> for CommandError

Source§

fn from(error: ValidateSubcommandError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> IntoResult<T> for T

Source§

type Err = !

Source§

fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>

Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more