pub struct BackendError {
pub kind: BackendErrorKind,
pub message: String,
pub source: Option<Box<dyn Error + Send + Sync>>,
}Expand description
A structured error from a cache backend.
Fields§
§kind: BackendErrorKindClassification of this error.
message: StringHuman-readable description.
source: Option<Box<dyn Error + Send + Sync>>The underlying error that caused this backend error, if any.
Implementations§
Source§impl BackendError
impl BackendError
Sourcepub fn transient(message: impl Into<String>) -> Self
pub fn transient(message: impl Into<String>) -> Self
Create a transient (retryable) backend error.
Sourcepub fn permanent(message: impl Into<String>) -> Self
pub fn permanent(message: impl Into<String>) -> Self
Create a permanent (non-retryable) backend error.
Sourcepub fn sanitize_message(msg: &str, api_key: &str) -> String
pub fn sanitize_message(msg: &str, api_key: &str) -> String
Sanitize error messages to strip API keys (CWE-532).
Sourcepub fn from_http_status(status: u16, body: &[u8]) -> Self
pub fn from_http_status(status: u16, body: &[u8]) -> Self
Construct a BackendError from an HTTP status code and response body.
The body is truncated to 256 Unicode scalar values to avoid inflating error messages.
Trait Implementations§
Source§impl Debug for BackendError
impl Debug for BackendError
Source§impl Display for BackendError
impl Display for BackendError
Source§impl Error for BackendError
impl Error for BackendError
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<BackendError> for CachekitError
impl From<BackendError> for CachekitError
Source§fn from(source: BackendError) -> Self
fn from(source: BackendError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for BackendError
impl !RefUnwindSafe for BackendError
impl Send for BackendError
impl Sync for BackendError
impl Unpin for BackendError
impl UnsafeUnpin for BackendError
impl !UnwindSafe for BackendError
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> 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> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.