v0.3.2-pre.005
This commit is contained in:
45
crates/ksp-store-postgres-lib/src/error.rs
Normal file
45
crates/ksp-store-postgres-lib/src/error.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
// file: crates/ksp-store-postgres-lib/src/error.rs
|
||||
// version: 1
|
||||
|
||||
/// Safe backend-local classification used by the Store facade for stable error mapping.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum PostgresBackendErrorKind {
|
||||
/// The supplied physical PostgreSQL configuration is unsupported or malformed.
|
||||
ConfigInvalid,
|
||||
/// A physical PostgreSQL connection could not be established.
|
||||
ConnectFailed,
|
||||
/// A bounded pool wait, create or recycle operation reached its deadline.
|
||||
PoolTimeout,
|
||||
/// Explicit backend shutdown did not drain inside the supplied deadline.
|
||||
ShutdownTimeout,
|
||||
/// Verified TLS configuration or negotiation could not be established.
|
||||
TlsFailed,
|
||||
}
|
||||
|
||||
/// Redacted PostgreSQL backend error carrying only a safe classification and static lifecycle phase.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct PostgresBackendError {
|
||||
kind: PostgresBackendErrorKind,
|
||||
phase: &'static str,
|
||||
}
|
||||
|
||||
impl PostgresBackendError {
|
||||
/// Creates one backend error without retaining external error text or sensitive connection material.
|
||||
#[must_use]
|
||||
pub(crate) const fn new(kind: PostgresBackendErrorKind, phase: &'static str) -> Self {
|
||||
return Self { kind, phase };
|
||||
}
|
||||
|
||||
/// Returns the safe backend-local error classification.
|
||||
#[must_use]
|
||||
pub const fn kind(&self) -> PostgresBackendErrorKind {
|
||||
return self.kind;
|
||||
}
|
||||
|
||||
/// Returns the static safe lifecycle phase associated with the failure.
|
||||
#[must_use]
|
||||
pub const fn phase(&self) -> &'static str {
|
||||
return self.phase;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user