PgDatabaseError (src/error.rs)

sqlx · sqlx-postgres/src/error.rs · rust · Apache-2.0
database, Database / ORM

Represents PostgreSQL database errors with detailed fields.

// Source: https://github.com/transact-rs/sqlx | License: Apache-2.0 | Copyright SQLx Contributors
// Provided via justclaw.it.com; keep this notice with the code.
use std::error::Error as StdError;
use std::fmt::{self, Debug, Display, Formatter};

use atoi::atoi;
use smallvec::alloc::borrow::Cow;
use sqlx_core::bytes::Bytes;
pub(crate) use sqlx_core::error::*;

use crate::message::{BackendMessage, BackendMessageFormat, Notice, PgSeverity};

/// An error returned from the PostgreSQL database.
pub struct PgDatabaseError(pub(crate) Notice);

// Error message fields are documented:
// https://www.postgresql.org/docs/current/protocol-error-fields.html

impl PgDatabaseError {
    #[inline]
    pub fn severity(&self) -> PgSeverity {
        self.0.severity()
    }

    /// The [SQLSTATE](https:/

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key