1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! `secure_errors` — Centralized error handling (OWASP C10).
//!
//! Provides a three-layer error model:
//! - **Internal layer** (`kind::AppError`): full internal details, never serialized to clients.
//! - **Public layer** (`public::PublicError`): the only type serialized to HTTP responses.
//! - **Operational layer** (`classify::ErrorClassification`): retryability, alerting, signals.
//!
//! # Feature flags
//!
//! | Flag | Default | Enables |
//! |---|---|---|
//! | `axum` | ✅ | [`middleware::ErrorMappingLayer`] tower layer + `impl IntoResponse for AppError` |
//! | `actix-web` | | `impl actix_web::ResponseError for AppError` (see [`actix`]) |
//!
//! Both paths route through the single-source-of-truth mapping in
//! [`http::into_response_parts`], so axum and actix-web responses for the
//! same `AppError` are byte-identical.
//!
//! # Design invariants
//! - `PublicError` is the **only** type that may be serialized to HTTP responses.
//! - `http::into_response_parts` is the **only** place that maps errors to HTTP status codes.
//! - No internal error text (SQL, hostnames, stack traces) may appear in `PublicError`.
/// Actix-web 4 integration — `impl ResponseError for AppError`.
///
/// Gated on the `actix-web` feature.
/// Kani proof harnesses (compiled only under `cargo kani`).
/// See `docs/dev-guide/formal-verification.md`.