secure_errors/lib.rs
1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3#![deny(clippy::all, clippy::pedantic)]
4//! `secure_errors` — Centralized error handling (OWASP C10).
5//!
6//! Provides a three-layer error model:
7//! - **Internal layer** (`kind::AppError`): full internal details, never serialized to clients.
8//! - **Public layer** (`public::PublicError`): the only type serialized to HTTP responses.
9//! - **Operational layer** (`classify::ErrorClassification`): retryability, alerting, signals.
10//!
11//! # Feature flags
12//!
13//! | Flag | Default | Enables |
14//! |---|---|---|
15//! | `axum` | ✅ | [`middleware::ErrorMappingLayer`] tower layer + `impl IntoResponse for AppError` |
16//! | `actix-web` | | `impl actix_web::ResponseError for AppError` (see [`actix`]) |
17//!
18//! Both paths route through the single-source-of-truth mapping in
19//! [`http::into_response_parts`], so axum and actix-web responses for the
20//! same `AppError` are byte-identical.
21//!
22//! # Design invariants
23//! - `PublicError` is the **only** type that may be serialized to HTTP responses.
24//! - `http::into_response_parts` is the **only** place that maps errors to HTTP status codes.
25//! - No internal error text (SQL, hostnames, stack traces) may appear in `PublicError`.
26
27pub mod capture;
28pub mod classify;
29pub mod context_propagation;
30pub mod http;
31pub mod incident;
32pub mod kind;
33#[cfg(feature = "axum")]
34pub mod middleware;
35pub mod panic;
36pub mod public;
37pub mod report;
38
39/// Actix-web 4 integration — `impl ResponseError for AppError`.
40///
41/// Gated on the `actix-web` feature.
42#[cfg(feature = "actix-web")]
43pub mod actix;