pub struct AlienError {
pub code: AlienErrorCode,
pub context: Option<Value>,
pub http_status_code: Option<i32>,
pub internal: bool,
pub message: AlienErrorMessage,
pub retryable: bool,
pub source: Option<Value>,
}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.
JSON schema
{
"description": "Canonical error container that provides a structured way to represent errors\nwith rich metadata including error codes, human-readable messages, context,\nand chaining capabilities for error propagation.\n\nThis struct is designed to be both machine-readable and user-friendly,\nsupporting serialization for API responses and detailed error reporting\nin distributed systems.",
"type": "object",
"required": [
"code",
"internal",
"message",
"retryable"
],
"properties": {
"code": {
"description": "A unique identifier for the type of error.\n\nThis should be a short, machine-readable string that can be used\nby clients to programmatically handle different error types.\nExamples: \"NOT_FOUND\", \"VALIDATION_ERROR\", \"TIMEOUT\"",
"examples": [
"NOT_FOUND"
],
"type": "string",
"maxLength": 128
},
"context": {
"description": "Additional diagnostic information about the error context.\n\nThis optional field can contain structured data providing more details\nabout the error, such as validation errors, request parameters that\ncaused the issue, or other relevant context information."
},
"httpStatusCode": {
"description": "HTTP status code for this error.\n\nUsed when converting the error to an HTTP response. If None, falls back to\nthe error type's default status code or 500.",
"type": [
"integer",
"null"
],
"format": "int32",
"maximum": 599.0,
"minimum": 100.0
},
"internal": {
"description": "Indicates if this is an internal error that should not be exposed to users.\n\nWhen `true`, this error contains sensitive information or implementation\ndetails that should not be shown to end-users. Such errors should be\nlogged for debugging but replaced with generic error messages in responses.",
"type": "boolean"
},
"message": {
"description": "Human-readable error message.\n\nThis message should be clear and actionable for developers or end-users,\nproviding context about what went wrong and potentially how to fix it.",
"examples": [
"Item not found."
],
"type": "string",
"maxLength": 16384
},
"retryable": {
"description": "Indicates whether the operation that caused the error should be retried.\n\nWhen `true`, the error is transient and the operation might succeed\nif attempted again. When `false`, retrying the same operation is\nunlikely to succeed without changes.",
"default": false,
"type": "boolean"
},
"source": {
"description": "The underlying error that caused this error, creating an error chain.\n\nThis allows for proper error propagation and debugging by maintaining\nthe full context of how an error occurred through multiple layers\nof an application."
}
}
}Fields§
§code: AlienErrorCodeA 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”
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.
http_status_code: Option<i32>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.
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.
message: AlienErrorMessageHuman-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.
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.
source: Option<Value>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.
Implementations§
Source§impl AlienError
impl AlienError
pub fn builder() -> AlienError
Trait Implementations§
Source§impl Clone for AlienError
impl Clone for AlienError
Source§fn clone(&self) -> AlienError
fn clone(&self) -> AlienError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more