Skip to main content

Error

Struct Error 

Source
pub struct Error(/* private fields */);
Expand description

An error from giong-postgres.

Every error says what happened and, where there is one, what to do about it. It is shown with the giong error code of its kind in front, and the link to that code’s page at the end: GIONG-E3003: password authentication failed for user "app". See https://…/E3003.md. kind tells errors apart in code; errors the server reported carry its fields in db, with the SQLSTATE code in server_code.

Errors are cheap to clone, and convert into std::io::Error, so ? works in functions that return io::Result; there, giong::error::code finds the code, and giong::error::Error::get_ref gives this error back.

Implementations§

Source§

impl Error

Source

pub fn conversion(message: impl Into<String>) -> Self

An error for a value that cannot be converted, for implementations of ToSql and FromSql. Say what the value was and what would work instead.

Source

pub fn kind(&self) -> ErrorKind

What kind of error this is.

Source

pub fn giong_code(&self) -> Code

The giong error code, the one shown in front of the message: one for each ErrorKind. For the server’s own code, see server_code.

Source

pub fn db(&self) -> Option<&DbError>

The error the server reported, for ErrorKind::Db (and for ErrorKind::Auth when the server refused the credentials).

Source

pub fn server_code(&self) -> Option<&str>

The SQLSTATE code of the server’s error, such as "23505" for a unique violation. The codes are listed in the PostgreSQL manual, appendix A. A COMMIT that the server turned into a rollback has "25P02" (in failed SQL transaction), with no db. For giong’s own code, see giong_code.

Source

pub fn is_transient(&self) -> bool

Whether trying again may succeed: the connection could not be opened or broke, no pooled connection became free in time, or the server reported a serialization failure (40001), a deadlock (40P01), a lock it could not take (55P03), too many connections (53300), a connection error (class 08), that it is shutting down or starting (57P01, 57P02, 57P03), or that it is a standby (25006, after a failover: a Pool opens a new connection for the next try).

A statement that changes data may have run before a Closed error: retrying it may run it twice. A transaction that failed with 40001 or 40P01 is retried from its start, not from the failed statement. A statement stopped by the statement timeout (57014) is not counted: it would most likely run as long again.

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Forget for Error

§

impl Freeze for Error
where *const ArcInner<Inner> is !null: Freeze, PhantomData<ArcInner<Inner>>: Freeze,

§

impl Move for Error

§

impl Send for Error
where Arc<Inner>: Send,

§

impl Sync for Error
where Arc<Inner>: Sync,

§

impl Unpin for Error
where Arc<Inner>: Unpin,

§

impl UnsafeUnpin for Error
where *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.