pub struct DatabaseError {
pub code: String,
pub message: String,
pub details: Option<String>,
pub hint: Option<String>,
pub constraint: Option<String>,
pub table: Option<String>,
pub column: Option<String>,
}Expand description
Database-specific error type.
Fields§
§code: StringThe five-character SQLSTATE. This decides the HTTP status, so it is the field that matters most.
message: StringPostgreSQL’s primary message.
details: Option<String>PostgreSQL’s detail field, where it sent one.
hint: Option<String>PostgreSQL’s hint field, where it sent one.
constraint: Option<String>The constraint that was violated, for the integrity SQLSTATEs.
table: Option<String>The table the failure concerns, where PostgreSQL identified one.
column: Option<String>The column the failure concerns, where PostgreSQL identified one.
Implementations§
Source§impl DatabaseError
impl DatabaseError
Sourcepub fn raised_response(&self) -> Option<Result<RaisedResponse, RaiseFault>>
pub fn raised_response(&self) -> Option<Result<RaisedResponse, RaiseFault>>
The response a RAISE sqlstate 'PGRST' asked for.
A function can take over the whole response by raising that SQLSTATE: the message is the body, and the detail carries the status, an optional status text and any headers. It is how a schema returns a 402 with its own payload without the API layer knowing anything about billing.
None when this is not that error. Err when it is and the schema
wrote it wrongly, which is a bug in the schema rather than a response
to half-apply.
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
The HTTP status a PostgreSQL error code maps to.
PostgREST’s table (mapSQLtoHTTP in Error.hs), which is part of its
contract rather than an implementation detail: a client distinguishes a
missing function from a bad argument by the status.
The default is 400, not 500: the great majority of SQLSTATEs a request can provoke are provoked by the request. Reporting them as server errors tells the client to retry something that will never succeed.
Trait Implementations§
Source§impl Debug for DatabaseError
impl Debug for DatabaseError
Source§impl Display for DatabaseError
impl Display for DatabaseError
Source§impl Error for DatabaseError
impl Error for DatabaseError
1.30.0 · 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<DatabaseError> for Error
impl From<DatabaseError> for Error
Source§fn from(source: DatabaseError) -> Self
fn from(source: DatabaseError) -> Self
Auto Trait Implementations§
impl Freeze for DatabaseError
impl RefUnwindSafe for DatabaseError
impl Send for DatabaseError
impl Sync for DatabaseError
impl Unpin for DatabaseError
impl UnsafeUnpin for DatabaseError
impl UnwindSafe for DatabaseError
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more