pub struct AlienError<T = GenericError>{
pub code: String,
pub message: String,
pub context: Option<Value>,
pub hint: Option<String>,
pub retryable: bool,
pub internal: bool,
pub http_status_code: Option<u16>,
pub source: Option<Box<AlienError<GenericError>>>,
pub human_layer_presentation: HumanLayerPresentation,
pub error: Option<T>,
}Expand description
Canonical error container that provides a structured way to represent errors with rich metadata including error codes, human-readable messages, context, and chaining capabilities for error propagation.
This struct is designed to be both machine-readable and user-friendly, supporting serialization for API responses and detailed error reporting in distributed systems.
Fields§
§code: StringA unique identifier for the type of error.
This should be a short, machine-readable string that can be used by clients to programmatically handle different error types. Examples: “NOT_FOUND”, “VALIDATION_ERROR”, “TIMEOUT”
message: StringHuman-readable error message.
This message should be clear and actionable for developers or end-users, providing context about what went wrong and potentially how to fix it.
context: Option<Value>Additional diagnostic information about the error context.
This optional field can contain structured data providing more details about the error, such as validation errors, request parameters that caused the issue, or other relevant context information.
hint: Option<String>Optional human-facing remediation hint.
retryable: boolIndicates whether the operation that caused the error should be retried.
When true, the error is transient and the operation might succeed
if attempted again. When false, retrying the same operation is
unlikely to succeed without changes.
internal: boolIndicates if this is an internal error that should not be exposed to users.
When true, this error contains sensitive information or implementation
details that should not be shown to end-users. Such errors should be
logged for debugging but replaced with generic error messages in responses.
http_status_code: Option<u16>HTTP status code for this error.
Used when converting the error to an HTTP response. If None, falls back to the error type’s default status code or 500.
source: Option<Box<AlienError<GenericError>>>The underlying error that caused this error, creating an error chain.
This allows for proper error propagation and debugging by maintaining the full context of how an error occurred through multiple layers of an application.
human_layer_presentation: HumanLayerPresentation§error: Option<T>The original error for pattern matching
Implementations§
Source§impl<T> AlienError<T>
impl<T> AlienError<T>
Source§impl<T> AlienError<T>
impl<T> AlienError<T>
Sourcepub fn into_generic(self) -> AlienError<GenericError>
pub fn into_generic(self) -> AlienError<GenericError>
Convert this AlienError
pub fn human_report(&self) -> HumanErrorReport
Trait Implementations§
Source§impl<T> Clone for AlienError<T>
impl<T> Clone for AlienError<T>
Source§fn clone(&self) -> AlienError<T>
fn clone(&self) -> AlienError<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<E> ContextError<E> for AlienError<E>
impl<E> ContextError<E> for AlienError<E>
Source§fn context<M: AlienErrorData + Clone + Debug + Serialize>(
self,
meta: M,
) -> AlienError<M>
fn context<M: AlienErrorData + Clone + Debug + Serialize>( self, meta: M, ) -> AlienError<M>
Source§impl<T> Debug for AlienError<T>
impl<T> Debug for AlienError<T>
Source§impl<'de, T> Deserialize<'de> for AlienError<T>
impl<'de, T> Deserialize<'de> for AlienError<T>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T> Display for AlienError<T>
impl<T> Display for AlienError<T>
impl<T> Eq for AlienError<T>
Source§impl<T> Error for AlienError<T>
impl<T> Error for AlienError<T>
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<T> PartialEq for AlienError<T>
impl<T> PartialEq for AlienError<T>
Source§fn eq(&self, other: &AlienError<T>) -> bool
fn eq(&self, other: &AlienError<T>) -> bool
self and other values to be equal, and is used by ==.