#[non_exhaustive]pub enum Error {
Client(Error),
Io(Error),
InvalidName(String),
InvalidTableDefinition(String),
NotFound(String),
AlreadyExists(String),
#[non_exhaustive] Other {
message: String,
source: Option<Box<dyn StdError + Send + Sync>>,
},
}Expand description
The error type for Hyper API operations.
This enum is #[non_exhaustive]: new variants and new fields on existing
struct variants may be added in minor releases. Match arms must include a
wildcard _ => pattern.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Client(Error)
Error from the underlying Hyper client.
Io(Error)
I/O error.
InvalidName(String)
Invalid name error (empty or too long).
InvalidTableDefinition(String)
Invalid table definition.
NotFound(String)
Database object not found (table, schema, etc.).
AlreadyExists(String)
Database object already exists.
#[non_exhaustive]Other
Generic error with a custom message.
Fields
This variant is marked as non-exhaustive
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(message: impl Into<String>) -> Self
pub fn new(message: impl Into<String>) -> Self
Creates a new error with the given message.
This is a convenience constructor for creating generic errors.
Sourcepub fn with_cause<E>(message: impl Into<String>, cause: E) -> Self
pub fn with_cause<E>(message: impl Into<String>, cause: E) -> Self
Creates a new error with a cause.
This is a convenience constructor for creating generic errors with a source.
Sourcepub fn kind(&self) -> Option<ErrorKind>
pub fn kind(&self) -> Option<ErrorKind>
Returns the error kind, if this is a client error.
This is available when the error originates from hyperdb_api_core::client::Error.
Use this for matching on error categories (e.g., ErrorKind::Connection).
Sourcepub fn sqlstate(&self) -> Option<&str>
pub fn sqlstate(&self) -> Option<&str>
Extracts the PostgreSQL SQLSTATE code from the error, if available.
This is only available for database query errors from the Hyper client.
§Example
use hyperdb_api::Error;
// Assuming we have a client error with SQLSTATE
// let err: Error = ...;
// if let Some("42P04") = err.sqlstate() {
// println!("Database already exists");
// }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