#[non_exhaustive]pub enum CoolError {
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
BadRequest(String)
4xx — String is the public message returned to the client.
NotAcceptable(String)
UnsupportedMediaType(String)
Forbidden(String)
NotFound(String)
Conflict(String)
Validation(String)
PreconditionFailed(String)
Codec(String)
5xx — String is operator-only detail. Never returned to clients;
the public message is a fixed canned string per variant.
Database(String)
Database error with only a stringified detail. Preserved for
back-compat; new code should prefer DatabaseTyped produced by
cratestack_sqlx::cool_error_from_sqlx.
DatabaseTyped(DbErrorInfo)
Database error with structured information preserved from the driver.
Use CoolError::db_sqlstate and CoolError::db_constraint to
access the typed fields without matching on this variant directly.
Internal(String)
Implementations§
Source§impl CoolError
impl CoolError
pub fn code(&self) -> &'static str
pub fn status_code(&self) -> StatusCode
Sourcepub fn public_message(&self) -> Cow<'_, str>
pub fn public_message(&self) -> Cow<'_, str>
Public, safe-to-expose message returned in HTTP responses.
For 4xx variants this is the caller-supplied string. For 5xx variants
this is a fixed canned message; the caller-supplied string flows to
detail instead and is recorded via tracing only.
Sourcepub fn detail(&self) -> Option<&str>
pub fn detail(&self) -> Option<&str>
Operator-only detail string. For 5xx variants this is the message
supplied at construction time; for 4xx variants this returns the same
string as public_message (callers are expected to pre-redact 4xx
messages they emit).
Sourcepub fn db_sqlstate(&self) -> Option<&str>
pub fn db_sqlstate(&self) -> Option<&str>
Returns the SQLSTATE code if this is a DatabaseTyped error with a
known code (e.g. "23505" for unique_violation).
Always returns None for the legacy Database(String) variant; to
get typed access, use cratestack_sqlx::cool_error_from_sqlx at the
conversion site.
Sourcepub fn db_constraint(&self) -> Option<&str>
pub fn db_constraint(&self) -> Option<&str>
Returns the constraint name if this is a DatabaseTyped error that
carries constraint information (e.g. "accounts_email_key").
Always returns None for the legacy Database(String) variant; to
get typed access, use cratestack_sqlx::cool_error_from_sqlx at the
conversion site.