pub struct SanthError { /* private fields */ }Expand description
The shared error type for the Santh ecosystem.
Every error carries:
- A stable error
code. - A human-readable
title. - A mandatory
fixhint starting with"Fix: ". - Optional diagnostic
context. - An optional source error chain.
- An optional
locationin source or configuration.
Implementations§
Source§impl SanthError
impl SanthError
Sourcepub fn new(
code: &'static str,
title: impl Into<String>,
) -> SanthErrorBuilder<NoFix>
pub fn new( code: &'static str, title: impl Into<String>, ) -> SanthErrorBuilder<NoFix>
Start building a new SanthError.
The returned builder enforces at compile time that .fix() is called
before .build().
Sourcepub fn actionable_message(&self) -> String
pub fn actionable_message(&self) -> String
Returns an actionable, human-readable message with all diagnostic details.
Secrets are redacted from the output. The source chain is included so that causal information is never lost.
Delegates to [compose_message], the single formatter shared with the
default SanthErrorContract::actionable_message, so the canonical
type and any domain error enum that implements the contract render
byte-identically.
Sourcepub fn with_context(
self,
key: impl Into<Cow<'static, str>>,
value: impl Display,
) -> Self
pub fn with_context( self, key: impl Into<Cow<'static, str>>, value: impl Display, ) -> Self
Add a key-value diagnostic context entry.
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 a source error to the cause chain.
Sourcepub fn with_location(self, location: ErrorLocation) -> Self
pub fn with_location(self, location: ErrorLocation) -> Self
Attach a location to the error.
Trait Implementations§
Source§impl Debug for SanthError
impl Debug for SanthError
Source§impl Display for SanthError
impl Display for SanthError
impl Eq for SanthError
Source§impl Error for SanthError
impl Error for SanthError
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()
Source§impl From<Error> for SanthError
impl From<Error> for SanthError
Source§impl From<Error> for SanthError
impl From<Error> for SanthError
Source§impl From<Error> for SanthError
impl From<Error> for SanthError
Source§impl From<FromUtf8Error> for SanthError
impl From<FromUtf8Error> for SanthError
Source§fn from(err: FromUtf8Error) -> Self
fn from(err: FromUtf8Error) -> Self
Converts to this type from the input type.
Source§impl PartialEq for SanthError
impl PartialEq for SanthError
Source§impl SanthErrorContract for SanthError
impl SanthErrorContract for SanthError
Source§fn error_code(&self) -> &'static str
fn error_code(&self) -> &'static str
Stable, machine-readable error code, e.g.
"KEYHOG-E001".Source§fn title(&self) -> Cow<'_, str>
fn title(&self) -> Cow<'_, str>
One-line human-readable title. Defaults to the
Display output, which is correct for
thiserror-style enums whose Display is the short message.Source§fn context(&self) -> Vec<(Cow<'static, str>, String)>
fn context(&self) -> Vec<(Cow<'static, str>, String)>
Key-value diagnostic context. Empty by default.
Source§fn location(&self) -> Option<&ErrorLocation>
fn location(&self) -> Option<&ErrorLocation>
Optional source or configuration location.
None by default.Source§fn actionable_message(&self) -> String
fn actionable_message(&self) -> String
Actionable, human-readable message: title, fix, context, location, and
the source chain, with secrets redacted. The default matches
SanthError exactly; override only for a custom layout.Auto Trait Implementations§
impl !RefUnwindSafe for SanthError
impl !UnwindSafe for SanthError
impl Freeze for SanthError
impl Send for SanthError
impl Sync for SanthError
impl Unpin for SanthError
impl UnsafeUnpin for SanthError
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