#[non_exhaustive]pub enum Error {
Show 20 variants
Connection {
message: String,
source: Option<Error>,
sqlstate: Option<String>,
},
Authentication(String),
Tls(String),
Server {
sqlstate: Option<String>,
message: String,
detail: Option<String>,
hint: Option<String>,
},
Protocol(String),
Io(Error),
Closed {
message: String,
sqlstate: Option<String>,
},
Timeout(String),
Cancelled {
message: String,
sqlstate: Option<String>,
},
Conversion(String),
Config(String),
FeatureNotSupported(String),
InvalidName(String),
InvalidTableDefinition(String),
NotFound(String),
AlreadyExists(String),
InvalidOperation(String),
Column {
name: String,
kind: ColumnErrorKind,
},
ColumnIndexOutOfBounds {
idx: usize,
column_count: usize,
},
Internal {
message: String,
},
}Expand description
The error type for Hyper API operations.
This enum is #[non_exhaustive]: new variants may be added in minor
releases, so match arms must include a wildcard _ => pattern.
Struct variants (Connection, Server, Column,
ColumnIndexOutOfBounds, Internal) cannot use Rust’s
#[non_exhaustive] (E0639), so forward-compatibility for new fields
relies on construction via the provided constructors:
Self::internalforSelf::InternalSelf::connection/Self::connection_with_ioforSelf::ConnectionSelf::serverforSelf::ServerSelf::columnforSelf::ColumnSelf::column_index_out_of_boundsforSelf::ColumnIndexOutOfBounds
Downstream code that uses struct-expression syntax for these variants will fail to compile if a new field is added in a minor release; using the constructors keeps callers source-compatible.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Connection
Connection-level failure (network, handshake, lifecycle, socket
I/O). Carries the underlying std::io::Error when one is
available; the type is erased at the wire-protocol boundary in
hyperdb-api-core, so source is None for errors that
originated there. sqlstate is set when the server provided a
connection-class SQLSTATE (e.g. 08001, 08006, 57P03).
Construct via Self::connection, Self::connection_with_io,
or Self::connection_with_sqlstate.
Fields
Authentication(String)
Authentication failed.
Tls(String)
TLS handshake or configuration failure.
Server
Server-side error (a SQL query or DDL command failed at the
server). sqlstate is the 5-character PostgreSQL SQLSTATE
code when the server reported one. detail and hint mirror
the structured fields the server may include in its error
response and are appended to the Display output when present.
Fields
Protocol(String)
Wire-protocol or framing error.
Io(Error)
Direct I/O error (file system, non-network sockets) at the SDK
boundary. Network I/O during connection lifecycle is reported as
Self::Connection instead.
Closed
Operation attempted on a closed connection. sqlstate is set
when the server provided one (typically 57P01 admin shutdown
or 57P02 crash shutdown). Construct via Self::closed or
Self::closed_with_sqlstate.
Fields
Timeout(String)
Operation timed out.
Cancelled
Operation was cancelled. sqlstate is set when the server
provided one (typically 57014 query_canceled). Construct via
Self::cancelled or Self::cancelled_with_sqlstate.
Fields
Conversion(String)
Type or value conversion failed (out-of-range numeric, malformed
binary value, scalar query returned no rows, etc.). For
column-specific decoding errors, prefer Self::Column.
Config(String)
Configuration error (invalid endpoint, missing env var, bad option combination).
FeatureNotSupported(String)
Feature is not supported on this connection or transport.
InvalidName(String)
Database identifier is invalid (empty, exceeds the PostgreSQL
63-byte limit, or violates other naming rules).
InvalidTableDefinition(String)
Table definition is invalid (zero columns, conflicting attributes).
NotFound(String)
Database object (schema, table, etc.) was not found.
AlreadyExists(String)
Database object already exists.
InvalidOperation(String)
Caller-API misuse: a method was called in an invalid sequence
or combination (e.g. mixing two mutually exclusive insertion
modes on a single inserter, calling a method after the resource
has been finalized). Distinct from Self::Internal, which is
reserved for true library invariant violations the caller could
not have triggered. Construct via Self::invalid_operation.
Column
Structured error for named-column access in row decoding. Used
by FromRow impls and Row::try_get / Row::get_by_name to
signal which column failed and why.
Fields
kind: ColumnErrorKindThe structured cause of the column-access failure.
ColumnIndexOutOfBounds
Column index was out of bounds for the row. Used for positional
access; named access uses Self::Column with
ColumnErrorKind::Missing.
Fields
Internal
Internal invariant violation — a state the library believes
should be unreachable. Callers cannot trigger this from the
public API in well-formed code; reaching it indicates a bug
inside hyperdb-api. Recovery is generally impossible beyond
logging and bailing.
For caller-API misuse (e.g. mixing two mutually exclusive
methods, using a finalized resource), prefer
Self::InvalidOperation.
Construct via Self::internal.
Implementations§
Source§impl Error
impl Error
Sourcepub fn internal(message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
Constructs an Self::Internal error. Prefer this over
struct-expression syntax to remain source-compatible if new
fields are added in a minor release.
Sourcepub fn connection(message: impl Into<String>) -> Self
pub fn connection(message: impl Into<String>) -> Self
Constructs an Self::Connection error with no underlying I/O
source and no SQLSTATE. Prefer this over struct-expression
syntax to remain source-compatible if new fields are added in a
minor release.
Sourcepub fn connection_with_io(message: impl Into<String>, source: Error) -> Self
pub fn connection_with_io(message: impl Into<String>, source: Error) -> Self
Constructs an Self::Connection error wrapping an underlying
std::io::Error. Prefer this over struct-expression syntax
to remain source-compatible if new fields are added in a minor
release.
Sourcepub fn connection_with_sqlstate(
message: impl Into<String>,
sqlstate: impl Into<String>,
) -> Self
pub fn connection_with_sqlstate( message: impl Into<String>, sqlstate: impl Into<String>, ) -> Self
Constructs an Self::Connection error carrying a SQLSTATE
code (typically 08* connection-class) and no I/O source.
Sourcepub fn server(
sqlstate: Option<String>,
message: impl Into<String>,
detail: Option<String>,
hint: Option<String>,
) -> Self
pub fn server( sqlstate: Option<String>, message: impl Into<String>, detail: Option<String>, hint: Option<String>, ) -> Self
Constructs an Self::Server error. Prefer this over
struct-expression syntax to remain source-compatible if new
fields are added in a minor release.
Sourcepub fn column(name: impl Into<String>, kind: ColumnErrorKind) -> Self
pub fn column(name: impl Into<String>, kind: ColumnErrorKind) -> Self
Constructs an Self::Column error. Prefer this over
struct-expression syntax to remain source-compatible if new
fields are added in a minor release.
Sourcepub fn column_index_out_of_bounds(idx: usize, column_count: usize) -> Self
pub fn column_index_out_of_bounds(idx: usize, column_count: usize) -> Self
Constructs an Self::ColumnIndexOutOfBounds error. Prefer
this over struct-expression syntax to remain source-compatible
if new fields are added in a minor release.
Sourcepub fn authentication(message: impl Into<String>) -> Self
pub fn authentication(message: impl Into<String>) -> Self
Constructs an Self::Authentication error.
Sourcepub fn protocol(message: impl Into<String>) -> Self
pub fn protocol(message: impl Into<String>) -> Self
Constructs an Self::Protocol error.
Sourcepub fn closed(message: impl Into<String>) -> Self
pub fn closed(message: impl Into<String>) -> Self
Constructs an Self::Closed error with no SQLSTATE.
Sourcepub fn closed_with_sqlstate(
message: impl Into<String>,
sqlstate: impl Into<String>,
) -> Self
pub fn closed_with_sqlstate( message: impl Into<String>, sqlstate: impl Into<String>, ) -> Self
Constructs an Self::Closed error carrying a SQLSTATE code
(typically 57P01 admin shutdown or 57P02 crash shutdown).
Sourcepub fn timeout(message: impl Into<String>) -> Self
pub fn timeout(message: impl Into<String>) -> Self
Constructs an Self::Timeout error.
Sourcepub fn cancelled(message: impl Into<String>) -> Self
pub fn cancelled(message: impl Into<String>) -> Self
Constructs an Self::Cancelled error with no SQLSTATE.
Sourcepub fn cancelled_with_sqlstate(
message: impl Into<String>,
sqlstate: impl Into<String>,
) -> Self
pub fn cancelled_with_sqlstate( message: impl Into<String>, sqlstate: impl Into<String>, ) -> Self
Constructs an Self::Cancelled error carrying a SQLSTATE
code (typically 57014 query_canceled).
Sourcepub fn conversion(message: impl Into<String>) -> Self
pub fn conversion(message: impl Into<String>) -> Self
Constructs an Self::Conversion error.
Sourcepub fn config(message: impl Into<String>) -> Self
pub fn config(message: impl Into<String>) -> Self
Constructs an Self::Config error.
Sourcepub fn feature_not_supported(message: impl Into<String>) -> Self
pub fn feature_not_supported(message: impl Into<String>) -> Self
Constructs an Self::FeatureNotSupported error.
Sourcepub fn invalid_name(message: impl Into<String>) -> Self
pub fn invalid_name(message: impl Into<String>) -> Self
Constructs an Self::InvalidName error.
Sourcepub fn invalid_table_definition(message: impl Into<String>) -> Self
pub fn invalid_table_definition(message: impl Into<String>) -> Self
Constructs an Self::InvalidTableDefinition error.
Sourcepub fn not_found(message: impl Into<String>) -> Self
pub fn not_found(message: impl Into<String>) -> Self
Constructs an Self::NotFound error.
Sourcepub fn already_exists(message: impl Into<String>) -> Self
pub fn already_exists(message: impl Into<String>) -> Self
Constructs an Self::AlreadyExists error.
Sourcepub fn invalid_operation(message: impl Into<String>) -> Self
pub fn invalid_operation(message: impl Into<String>) -> Self
Constructs an Self::InvalidOperation error.
Sourcepub fn message(&self) -> String
pub fn message(&self) -> String
Returns the error message in human-readable form. Equivalent to
self.to_string().
Sourcepub fn sqlstate(&self) -> Option<&str>
pub fn sqlstate(&self) -> Option<&str>
Returns the PostgreSQL SQLSTATE code if this error carries
one, otherwise None.
Returns Some(...) for Self::Server (Query-class codes),
Self::Connection (typically 08*), Self::Closed
(typically 57P0* shutdown codes), and Self::Cancelled
(typically 57014 query_canceled) when the underlying server
provided a code.
SQLSTATE codes are 5-character strings — see the PostgreSQL
errcodes appendix.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Infallible> for Error
impl From<Infallible> for Error
Source§fn from(_: Infallible) -> Self
fn from(_: Infallible) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request