pub struct AdminError {
pub status: StatusCode,
pub code: &'static str,
pub message: String,
/* private fields */
}Expand description
A failed admin request.
Clone so pages::refuse_with_card can render a refusal and keep the
borrowed original: it builds the response from into_response, which
consumes, and the caller still owns the error it was handed.
Fields§
§status: StatusCode§code: &'static strStable, machine-readable, snake_case. Never a URN.
message: StringImplementations§
Source§impl AdminError
impl AdminError
Sourcepub fn bad_request(message: impl Into<String>) -> Self
pub fn bad_request(message: impl Into<String>) -> Self
400 — the request body or query string did not make sense.
Sourcepub fn session_invalid() -> Self
pub fn session_invalid() -> Self
401 — no usable session. Every reason a login can fail collapses to
AdminError::invalid_credentials; this one is for a request that
arrived without a live session.
Sourcepub fn session_expired() -> Self
pub fn session_expired() -> Self
401 — the session passed its absolute deadline.
Sourcepub fn session_idle() -> Self
pub fn session_idle() -> Self
401 — the session went unused for longer than the idle timeout.
Sourcepub fn invalid_credentials() -> Self
pub fn invalid_credentials() -> Self
401 — the login failed.
One code for every cause: unknown username, wrong password, and a
disabled account are indistinguishable to the client on purpose, so the
endpoint cannot be used to enumerate operators. The log says which
(see crate::admin::users::AuthOutcome).
Sourcepub fn csrf_failed(message: impl Into<String>) -> Self
pub fn csrf_failed(message: impl Into<String>) -> Self
403 — the CSRF token was missing, wrong, or the request came from
another origin.
Sourcepub fn insufficient_role() -> Self
pub fn insufficient_role() -> Self
403 — the session is live, but the operator’s role does not permit
this action (crates/store/src/admin_user.rs’s AdminRole). Not a 401: the
answer is not “sign in again”, so to_page_error renders it as a banner
rather than a redirect to the login form.
Sourcepub fn with_code(
status: StatusCode,
code: &'static str,
message: impl Into<String>,
) -> Self
pub fn with_code( status: StatusCode, code: &'static str, message: impl Into<String>, ) -> Self
405/404 fallbacks and any other conflict-free refusal with its own
code.
Sourcepub fn conflict(code: &'static str, message: impl Into<String>) -> Self
pub fn conflict(code: &'static str, message: impl Into<String>) -> Self
409 — the request was well-formed but the row is in the wrong state.
Sourcepub fn rate_limited(retry_after_seconds: u64) -> Self
pub fn rate_limited(retry_after_seconds: u64) -> Self
429 — too many failed logins from this address.
Sourcepub fn signer_failed(message: impl Into<String>) -> Self
pub fn signer_failed(message: impl Into<String>) -> Self
502 — the signer backend refused or could not be reached.
Sourcepub fn access_denied(message: impl Into<String>) -> Self
pub fn access_denied(message: impl Into<String>) -> Self
403 — admin.filter refused the caller before any handler ran.
Trait Implementations§
Source§impl Clone for AdminError
impl Clone for AdminError
Source§impl Debug for AdminError
impl Debug for AdminError
Source§impl Display for AdminError
impl Display for AdminError
impl Eq for AdminError
Source§impl Error for AdminError
impl Error for AdminError
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<AdminError> for PageError
A 401 from the API layer means “sign in”; everything else keeps its status.
impl From<AdminError> for PageError
A 401 from the API layer means “sign in”; everything else keeps its status.
This is the one place the two error vocabularies meet, and it is a
conversion rather than a shared type on purpose: AdminError answers a
script, PageError answers a browser, and the day one grows a member the
other should not have, nothing has to be untangled.
Source§fn from(error: AdminError) -> Self
fn from(error: AdminError) -> Self
Source§impl From<Error> for AdminError
A database failure is logged and answered generically.
impl From<Error> for AdminError
A database failure is logged and answered generically.
The sqlx message names tables and columns, which is schema disclosure on
an authenticated-but-not-necessarily-trusted surface — it belongs in the
log, where the operator can read it, and not in the body.
Source§impl IntoResponse for AdminError
impl IntoResponse for AdminError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Source§impl PartialEq for AdminError
impl PartialEq for AdminError
impl StructuralPartialEq for AdminError
Auto Trait Implementations§
impl Freeze for AdminError
impl RefUnwindSafe for AdminError
impl Send for AdminError
impl Sync for AdminError
impl Unpin for AdminError
impl UnsafeUnpin for AdminError
impl UnwindSafe for AdminError
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T, S> Handler<IntoResponseHandler, S> for T
impl<T, S> Handler<IntoResponseHandler, S> for T
Source§fn call(
self,
_req: Request<Body>,
_state: S,
) -> <T as Handler<IntoResponseHandler, S>>::Future
fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future
Source§fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>where
L: Layer<HandlerService<Self, T, S>> + Clone,
<L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,
tower::Layer to the handler. Read moreSource§fn with_state(self, state: S) -> HandlerService<Self, T, S>
fn with_state(self, state: S) -> HandlerService<Self, T, S>
Service by providing the stateSource§impl<H, T> HandlerWithoutStateExt<T> for H
impl<H, T> HandlerWithoutStateExt<T> for H
Source§fn into_service(self) -> HandlerService<H, T, ()>
fn into_service(self) -> HandlerService<H, T, ()>
Service and no state.Source§fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>
MakeService and no state. Read moreSource§fn into_make_service_with_connect_info<C>(
self,
) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>
MakeService which stores information
about the incoming connection and has no state. Read moreimpl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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