pub struct AshError { /* private fields */ }Expand description
Main error type for ASH operations.
Error messages are designed to be safe for logging and client responses. They never contain sensitive data like payloads, proofs, or canonical strings.
§Two-Layer Error Model
- Wire layer (
code/http_status/message): Conformance-locked. These values are tested by the 134-vector conformance suite and must not change. - Diagnostic layer (
reason/details): Internal only. Provides granular classification for logging and debugging without affecting wire behavior.
Implementations§
Source§impl AshError
impl AshError
Sourcepub fn new(code: AshErrorCode, message: impl Into<String>) -> Self
pub fn new(code: AshErrorCode, message: impl Into<String>) -> Self
Create a new AshError with General reason (backward compatible).
Sourcepub fn with_reason(
code: AshErrorCode,
reason: InternalReason,
message: impl Into<String>,
) -> Self
pub fn with_reason( code: AshErrorCode, reason: InternalReason, message: impl Into<String>, ) -> Self
Create a new AshError with a specific internal reason.
Sourcepub fn with_detail(self, key: &'static str, value: impl Into<String>) -> Self
pub fn with_detail(self, key: &'static str, value: impl Into<String>) -> Self
Add a diagnostic detail (builder pattern). Must not contain secrets.
Sourcepub fn code(&self) -> AshErrorCode
pub fn code(&self) -> AshErrorCode
Get the error code.
Sourcepub fn http_status(&self) -> u16
pub fn http_status(&self) -> u16
Get the recommended HTTP status code.
Sourcepub fn reason(&self) -> InternalReason
pub fn reason(&self) -> InternalReason
Get the internal diagnostic reason.
Source§impl AshError
Convenience functions for creating common errors.
impl AshError
Convenience functions for creating common errors.
Sourcepub fn ctx_not_found() -> Self
pub fn ctx_not_found() -> Self
Context not found.
Sourcepub fn ctx_expired() -> Self
pub fn ctx_expired() -> Self
Context expired.
Sourcepub fn ctx_already_used() -> Self
pub fn ctx_already_used() -> Self
Context already used (replay detected).
Sourcepub fn binding_mismatch() -> Self
pub fn binding_mismatch() -> Self
Binding mismatch.
Sourcepub fn proof_missing() -> Self
pub fn proof_missing() -> Self
Proof missing.
Sourcepub fn proof_invalid() -> Self
pub fn proof_invalid() -> Self
Proof invalid.
Sourcepub fn canonicalization_error() -> Self
pub fn canonicalization_error() -> Self
Canonicalization error.
PT-002: Uses a fixed message to prevent caller-provided data from leaking into error messages. All canonicalization failures produce the same generic message regardless of the specific failure reason.