pub struct CliError {
pub error_type: String,
pub title: String,
pub detail: String,
pub suggestion: Option<String>,
pub docs_url: Option<String>,
pub context: HashMap<String, Value>,
pub exit_code: i32,
}Expand description
Structured error following RFC 9457 (Problem Details) style.
Provides machine-readable error information with human-friendly presentation.
Fields§
§error_type: StringError type identifier (machine-readable).
title: StringShort human-readable title.
detail: StringDetailed explanation.
suggestion: Option<String>Suggested action for recovery.
docs_url: Option<String>Related documentation URL.
context: HashMap<String, Value>Additional context (varies by error type).
exit_code: i32Exit code for this error.
Implementations§
Source§impl CliError
impl CliError
Sourcepub fn new(error_type: impl Into<String>, title: impl Into<String>) -> Self
pub fn new(error_type: impl Into<String>, title: impl Into<String>) -> Self
Create a new CLI error.
Sourcepub fn suggestion(self, suggestion: impl Into<String>) -> Self
pub fn suggestion(self, suggestion: impl Into<String>) -> Self
Add a suggested recovery action.
Sourcepub fn human_format(&self, color: bool) -> String
pub fn human_format(&self, color: bool) -> String
Format for human output.
When color is true, includes ANSI escape codes for terminal coloring.
Sourcepub fn json_format(&self) -> String
pub fn json_format(&self) -> String
Format as JSON.
Sourcepub fn json_pretty_format(&self) -> String
pub fn json_pretty_format(&self) -> String
Format as pretty JSON.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CliError
impl<'de> Deserialize<'de> for CliError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for CliError
impl Error for CliError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for CliError
impl RefUnwindSafe for CliError
impl Send for CliError
impl Sync for CliError
impl Unpin for CliError
impl UnwindSafe for CliError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).