Alien-Error – minimal clean version with context-based API.
Provides:
• AlienErrorMetadata trait (implemented by enums via #[derive(AlienError)])
• AlienError<T> container (generic over error type)
• .context() extension method for AlienError Results
• .into_alien_error() for converting std errors
• Result<T> alias
• OpenAPI schema generation (with openapi feature)
• Axum IntoResponse implementation (with axum feature)
Use .context(YourError::Variant { ... }) on AlienError Results to wrap errors.
Use .into_alien_error() on std::error::Error Results to convert them first.
OpenAPI Schema Generation
When the openapi feature is enabled, the AlienError struct implements
utoipa::ToSchema, allowing it to be used in OpenAPI documentation:
use OpenApi;
use AlienError;
;
Axum Integration
When the axum feature is enabled, AlienError implements axum::response::IntoResponse,
allowing it to be returned directly from Axum handlers. By default, the IntoResponse
implementation uses external response behavior (sanitizes internal errors).
For different use cases, you can choose between:
External API Responses (Default)
use IntoResponse;
use ;
// Default behavior - sanitizes internal errors for security
async
// Returns: HTTP 500 with {"code": "GENERIC_ERROR", "message": "Internal server error"}
Explicit External Responses
async
Internal Service Communication
async
// Returns: HTTP 500 with full error details including sensitive information