pub struct TuffError { /* private fields */ }Expand description
One failure, with the kind of thing that went wrong, what happened, and optionally what to do about it.
Implementations§
Source§impl TuffError
impl TuffError
Sourcepub fn of(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn of(kind: ErrorKind, message: impl Into<String>) -> Self
Build an error of a given kind. Prefer the per-kind constructors.
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
An error for an invariant Tuff itself broke.
This is also the landing spot for messages not yet classified during the migration to typed kinds, which is why the lint gate counts its uses outside this module and only lets that count fall.
pub fn usage(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
pub fn refused(message: impl Into<String>) -> Self
pub fn drift(message: impl Into<String>) -> Self
pub fn source_failed(message: impl Into<String>) -> Self
pub fn corrupt(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
Sourcepub fn with_hint(self, hint: impl Into<String>) -> Self
pub fn with_hint(self, hint: impl Into<String>) -> Self
Attach one imperative line telling the user what to do next. Kept
separate from the message so --json can carry it as its own field
and humans get it on its own line.
Sourcepub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
pub fn with_source(self, source: impl Error + Send + Sync + 'static) -> Self
Attach the underlying error, preserving the cause chain.
pub fn kind(&self) -> ErrorKind
pub fn message(&self) -> &str
pub fn hint(&self) -> Option<&str>
pub fn exit_code(&self) -> i32
Trait Implementations§
Source§impl Error for TuffError
impl Error for TuffError
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 !RefUnwindSafe for TuffError
impl !UnwindSafe for TuffError
impl Freeze for TuffError
impl Send for TuffError
impl Sync for TuffError
impl Unpin for TuffError
impl UnsafeUnpin for TuffError
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