pub enum Error {
Show 48 variants
InvalidPath(String),
AggregatesNotAllowed,
InvalidQueryParam(String),
UnparsableQuery {
kind: &'static str,
text: String,
column: usize,
expected: String,
},
InvalidHeader(&'static str),
InvalidBody(String),
UnsupportedMethod(String),
InvalidRpcMethod(String),
UnacceptableSchema {
requested: String,
exposed: Vec<String>,
},
UnknownColumn {
column: String,
relation: String,
},
InvalidRange(String),
InvalidMediaType(String),
MissingParameter(String),
AmbiguousRequest(String),
AmbiguousFunction {
candidates: Vec<String>,
},
AmbiguousRelationship {
origin: String,
target: String,
candidates: Vec<(String, String)>,
disambiguated: Vec<String>,
},
InvalidJwt(String),
NoSuitableJwtKey,
JwtSecretMissing,
JwtClaim(String),
MissingAuth,
InsufficientPermissions(String),
NotFound(String),
TableNotFound {
name: String,
suggestion: Option<String>,
},
FunctionNotFound {
name: String,
params: Vec<String>,
candidate: Option<String>,
single_param: Option<String>,
},
RaiseNotUnderstood(RaiseFault),
MissingGeometryColumn,
ColumnNotFound(String),
RelationshipNotFound {
origin: String,
target: String,
hint: Option<String>,
schema: String,
suggestion: Option<String>,
},
NotAnEmbeddedResource(String),
RelatedOrderNotPossible {
origin: String,
relation: String,
},
NotSingular {
rows: usize,
},
InvalidResourcePath,
InvalidPutFilters,
PutLimitNotAllowed,
PutMatchingPk,
InvalidGucHeaders,
InvalidGucStatus,
MaxAffectedExceeded(i64),
InvalidPreferences(Vec<String>),
SchemaCacheNotLoaded,
SchemaCacheLoadFailed(String),
Database(DatabaseError),
ConnectionPool(String),
Internal(String),
Config(String),
InvalidPlan(String),
EmbeddingError(String),
}Expand description
Main error type for Postrust.
Variants§
InvalidPath(String)
AggregatesNotAllowed
An aggregate was requested while db-aggregates-enabled is off.
Off is the default, matching PostgREST: an unrestricted aggregate over a large table is an easy way to make a server do far more work than the request looks like it asks for.
InvalidQueryParam(String)
UnparsableQuery
A fragment of the query string the grammar could not read.
Reported the way a parser reports: what was being read, the text as the client wrote it, where reading stopped, and what would have been accepted there. All four are the client’s own input or the API’s own grammar, so none of it is a disclosure – and without them the client is told only that something in a URL it wrote is wrong.
Fields
InvalidHeader(&'static str)
InvalidBody(String)
UnsupportedMethod(String)
InvalidRpcMethod(String)
A method a function cannot be called with.
A function is invoked with GET, HEAD or POST. The others are refused with a message that says so rather than one about the method in general, since the method is fine elsewhere in the API.
UnacceptableSchema
A profile header named a schema the server does not expose.
Carries the schemas that are exposed, because the client needs them to correct the request and they are part of the API’s own contract.
UnknownColumn
Fields
InvalidRange(String)
InvalidMediaType(String)
MissingParameter(String)
AmbiguousRequest(String)
AmbiguousFunction
Several signatures of a function fit the arguments equally well.
AmbiguousRelationship
Several relationships connect the two resources and none was named.
Fields
InvalidJwt(String)
The token could not be decoded or its signature did not verify.
Distinct from a claims error: nothing about the token was readable, so there is nothing to say about what it claimed.
NoSuitableJwtKey
No key this server holds could decode the token.
Its own code would be indistinguishable from any other decode failure, so what separates it is the detail: the client is being told to look at which key signed the token, not at the token’s contents.
JwtSecretMissing
The server is configured to read tokens and has nothing to read them with. A fault in the deployment, not in the request.
JwtClaim(String)
The token decoded, but a claim was missing, malformed or unsatisfied.
MissingAuth
InsufficientPermissions(String)
NotFound(String)
TableNotFound
Fields
FunctionNotFound
No function of that name accepts the arguments supplied.
Carries what was looked for so the client can see why nothing matched: the name, the argument names it was called with, and the signature of an overload that does exist, where one does.
Fields
single_param: Option<String>The type of a single unnamed parameter that would also have matched, spelled as the message spells it.
Over POST the whole body can be one argument, and which type it
could be is decided by the body’s media type: json/jsonb for a
JSON body, text, xml or bytea for the others. Naming it says
what else was looked for besides the arguments themselves.
RaiseNotUnderstood(RaiseFault)
A RAISE sqlstate 'PGRST' the schema wrote wrongly.
The message and the detail are both JSON documents with required keys, and a function that gets one wrong has not asked for a response – it has a bug. Reporting it as the 500 it is says so; applying half of what it asked for would not.
MissingGeometryColumn
Accept: application/geo+json on rows that carry no geometry.
PostGIS raises this from ST_AsGeoJSON on a record with no geometry
column, and it is a database error rather than one of PostgREST’s own
– so it keeps the SQLSTATE it came with.
ColumnNotFound(String)
RelationshipNotFound
Fields
NotAnEmbeddedResource(String)
A filter or order names something the request never embedded.
?non_existent.name=like.*x* is not a column with a dot in it, and
answering it as though the prefix were meaningless would silently
return the unfiltered table.
RelatedOrderNotPossible
Ordering by a column of a resource that yields many rows per parent.
There is no single value to order on: the parent has a list.
Fields
NotSingular
A single object was asked for and the result is not one.
Accept: application/vnd.pgrst.object+json says the client will accept
exactly one row; anything else is a negotiation failure rather than a
missing resource, which is why it is 406 and not 404.
InvalidResourcePath
A path with more segments than any resource has.
InvalidPutFilters
A PUT whose filters do not name exactly one row by its key.
PUT writes the row the URL names, so the URL has to name exactly one:
every primary key column, with eq, and nothing else.
PutLimitNotAllowed
A PUT carrying a page.
PutMatchingPk
A PUT whose body names a different row from its URL.
InvalidGucHeaders
A function set response.headers to something that is not headers.
InvalidGucStatus
A function set response.status to something that is not a status.
MaxAffectedExceeded(i64)
A mutation touched more rows than Prefer: max-affected allowed.
The preference is a guard against a filter that turned out to match more than the client meant; nothing is committed when it trips.
InvalidPreferences(Vec<String>)
Preferences the server does not know, sent with handling=strict.
Strict handling is a request to be told rather than have them ignored.
SchemaCacheNotLoaded
SchemaCacheLoadFailed(String)
Database(DatabaseError)
ConnectionPool(String)
Internal(String)
Config(String)
InvalidPlan(String)
EmbeddingError(String)
Implementations§
Source§impl Error
impl Error
Sourcepub fn status_code(&self) -> StatusCode
pub fn status_code(&self) -> StatusCode
Get the HTTP status code for this error.
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()
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 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> 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