pub struct ChieError {
pub kind: ErrorKind,
pub message: String,
pub context: Vec<String>,
}Expand description
Enhanced error type with context information
This error type wraps the underlying error with additional context about where and why the error occurred.
Fields§
§kind: ErrorKindThe kind of error that occurred
message: StringHuman-readable error message
context: Vec<String>Optional context about where/why the error occurred
Implementations§
Source§impl ChieError
impl ChieError
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
Create a new error with the specified kind and message
Sourcepub fn validation(message: impl Into<String>) -> Self
pub fn validation(message: impl Into<String>) -> Self
Create a validation error
Sourcepub fn serialization(message: impl Into<String>) -> Self
pub fn serialization(message: impl Into<String>) -> Self
Create a serialization error
Sourcepub fn cryptographic(message: impl Into<String>) -> Self
pub fn cryptographic(message: impl Into<String>) -> Self
Create a cryptographic error
Sourcepub fn resource_exhausted(message: impl Into<String>) -> Self
pub fn resource_exhausted(message: impl Into<String>) -> Self
Create a resource exhausted error
Sourcepub fn already_exists(message: impl Into<String>) -> Self
pub fn already_exists(message: impl Into<String>) -> Self
Create an already exists error
Sourcepub fn permission_denied(message: impl Into<String>) -> Self
pub fn permission_denied(message: impl Into<String>) -> Self
Create a permission denied error
Sourcepub fn context(self, ctx: impl Into<String>) -> Self
pub fn context(self, ctx: impl Into<String>) -> Self
Add context to the error
§Examples
use chie_shared::ChieError;
let err = ChieError::validation("Invalid CID")
.context("While validating content metadata")
.context("In upload handler");Sourcepub fn is_transient(&self) -> bool
pub fn is_transient(&self) -> bool
Check if this is a transient error that might succeed on retry
Sourcepub fn is_permanent(&self) -> bool
pub fn is_permanent(&self) -> bool
Check if this is a permanent error that won’t succeed on retry
Sourcepub fn full_message(&self) -> String
pub fn full_message(&self) -> String
Get the full error message with context
Sourcepub fn report_telemetry(&self)
pub fn report_telemetry(&self)
Report this error to telemetry if a handler is set
This allows errors to be reported to external monitoring systems.
The global telemetry handler must be set using set_telemetry_handler.
Sourcepub fn new_with_telemetry(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn new_with_telemetry(kind: ErrorKind, message: impl Into<String>) -> Self
Create an error and immediately report it to telemetry