auths_crypto/error.rs
1//! Shared error trait for structured error codes across all Auths crates.
2
3/// Trait for error metadata providing structured error codes and actionable suggestions.
4///
5/// All user-facing Auths error types implement this trait to provide:
6/// - A unique error code for programmatic handling (e.g., `AUTHS-E3001`)
7/// - An optional human-readable suggestion for how to resolve the error
8///
9/// Args:
10/// (no arguments — this is a trait definition)
11///
12/// Usage:
13/// ```ignore
14/// use auths_crypto::AuthsErrorInfo;
15///
16/// impl AuthsErrorInfo for MyError {
17/// fn error_code(&self) -> &'static str { "AUTHS-E0001" }
18/// fn suggestion(&self) -> Option<&'static str> { None }
19/// }
20/// ```
21pub trait AuthsErrorInfo {
22 /// Returns a unique error code string for this error variant.
23 fn error_code(&self) -> &'static str;
24
25 /// Returns an optional actionable suggestion for resolving the error.
26 fn suggestion(&self) -> Option<&'static str>;
27}