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
impl Error
Sourcepub fn conversion(message: impl Into<String>) -> Self
pub fn conversion(message: impl Into<String>) -> Self
Sourcepub fn giong_code(&self) -> Code
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.
Sourcepub fn db(&self) -> Option<&DbError>
pub fn db(&self) -> Option<&DbError>
The error the server reported, for ErrorKind::Db (and for
ErrorKind::Auth when the server refused the credentials).
Sourcepub fn server_code(&self) -> Option<&str>
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.
Sourcepub fn is_transient(&self) -> bool
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 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()