pub struct Error { /* private fields */ }Expand description
The error type for Hyper client operations.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, message: impl Into<String>) -> Self
Creates a new error with the given kind and message.
Sourcepub fn with_cause<E>(
kind: ErrorKind,
message: impl Into<String>,
cause: E,
) -> Self
pub fn with_cause<E>( kind: ErrorKind, message: impl Into<String>, cause: E, ) -> Self
Creates a new error with a cause.
Sourcepub fn new_with_details(
kind: ErrorKind,
message: impl Into<String>,
detail: Option<String>,
hint: Option<String>,
sqlstate: Option<String>,
) -> Self
pub fn new_with_details( kind: ErrorKind, message: impl Into<String>, detail: Option<String>, hint: Option<String>, sqlstate: Option<String>, ) -> Self
Creates a new error with additional details (SQLSTATE, detail, hint).
This is primarily used for gRPC errors that carry structured error information.
Sourcepub fn connection(message: impl Into<String>) -> Self
pub fn connection(message: impl Into<String>) -> Self
Creates a connection error.
Sourcepub fn authentication(message: impl Into<String>) -> Self
pub fn authentication(message: impl Into<String>) -> Self
Creates an authentication error.
Sourcepub fn db(severity: &str, code: &str, message: &str) -> Self
pub fn db(severity: &str, code: &str, message: &str) -> Self
Creates an error from a database error response.
Sourcepub fn feature_not_supported(message: impl Into<String>) -> Self
pub fn feature_not_supported(message: impl Into<String>) -> Self
Creates a “feature not supported” error.
Used when an operation is not available on a particular connection type (e.g., write operations on gRPC connections).
Sourcepub fn sqlstate(&self) -> Option<&str>
pub fn sqlstate(&self) -> Option<&str>
Extracts the PostgreSQL SQLSTATE code from the error, if present.
SQLSTATE codes are 5-character codes that identify error conditions. See: https://www.postgresql.org/docs/current/errcodes-appendix.html
§Example
use hyperdb_api_core::client::{Error, ErrorKind};
let err = Error::db("ERROR", "42P04", "database already exists");
assert_eq!(err.sqlstate(), Some("42P04"));Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
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