pub struct ProgrammaticError {
pub message: String,
pub exit_code: u8,
pub code: Option<String>,
pub help: Option<String>,
pub context: Option<String>,
}Expand description
Structured error surface for the programmatic API.
Fields§
§message: StringHuman-readable description; also the Display output.
exit_code: u8Process exit code the CLI maps this failure to.
code: Option<String>Stable machine-readable code such as FALLOW_INVALID_COVERAGE_PATH.
help: Option<String>Optional remediation hint for the caller.
context: Option<String>Dotted path of the offending input, such as health.coverage.
Implementations§
Source§impl ProgrammaticError
impl ProgrammaticError
Sourcepub fn new(message: impl Into<String>, exit_code: u8) -> Self
pub fn new(message: impl Into<String>, exit_code: u8) -> Self
Create an error from the required message and exit code, with all optional fields left empty.
Sourcepub fn with_help(self, help: impl Into<String>) -> Self
pub fn with_help(self, help: impl Into<String>) -> Self
Attach a remediation hint shown to the caller alongside the message.
Sourcepub fn with_code(self, code: impl Into<String>) -> Self
pub fn with_code(self, code: impl Into<String>) -> Self
Attach a stable machine-readable code such as
FALLOW_INVALID_COVERAGE_PATH.
Sourcepub fn with_context(self, context: impl Into<String>) -> Self
pub fn with_context(self, context: impl Into<String>) -> Self
Attach the dotted path of the offending input, such as
health.coverage.
Trait Implementations§
Source§impl Clone for ProgrammaticError
impl Clone for ProgrammaticError
Source§impl Debug for ProgrammaticError
impl Debug for ProgrammaticError
Source§impl Display for ProgrammaticError
impl Display for ProgrammaticError
Source§impl Error for ProgrammaticError
impl Error for ProgrammaticError
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 ProgrammaticError
impl RefUnwindSafe for ProgrammaticError
impl Send for ProgrammaticError
impl Sync for ProgrammaticError
impl Unpin for ProgrammaticError
impl UnsafeUnpin for ProgrammaticError
impl UnwindSafe for ProgrammaticError
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: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more