pub struct ActionError {
pub message: String,
pub kind: ActionKind,
pub flash_variant: FlashVariant,
pub redirect_override: Option<String>,
/* private fields */
}Expand description
Action-handler error type. Drives the 303 redirect, the session flash
payload, the back-compat query string, and the tracing::error! log line.
§Security
message is rendered to users via the flash payload. Consumer templates
MUST HTML-escape it (T-180-01). redirect_override is validated as
same-origin at use time (T-180-02).
Fields§
§message: StringUser-facing error message. Treat as untrusted; templates must HTML-escape (T-180-01).
kind: ActionKindSemantic kind used for routing and back-compat query strings.
flash_variant: FlashVariantFlash banner variant picked up by consumer templates.
redirect_override: Option<String>Optional redirect override. Validated as same-origin when applied (T-180-02).
Implementations§
Source§impl ActionError
impl ActionError
Sourcepub fn validation_failed(redirect_to: impl Into<String>) -> Self
pub fn validation_failed(redirect_to: impl Into<String>) -> Self
Constructor for handlers that have already flashed per-field validation
errors via ValidationError::with_old_input(&data).redirect_to(url) (or
equivalently via ValidationError::into_action_error(url)).
Drives the 303 redirect WITHOUT writing the URL ?error=...&msg=...
envelope (which would render a redundant generic toast alongside the
per-field inline errors). Also skips the _action session flash write.
The 303 status, the Location header, and the tracing::error! log line
still emit unconditionally.
401-shape error.
redirect_override defaults to None — ferro is project-agnostic and
does not hardcode any consumer auth path (D-08). Callers configure
the redirect target explicitly:
ActionError::unauthorized("...").redirect_to("/your-login-path").
Sourcepub fn with_flash(self, variant: FlashVariant) -> Self
pub fn with_flash(self, variant: FlashVariant) -> Self
Builder — set the flash variant.
Sourcepub fn redirect_to(self, url: impl Into<String>) -> Self
pub fn redirect_to(self, url: impl Into<String>) -> Self
Builder — set the redirect override. The override is validated as
same-origin (T-180-02) when applied by the action runtime; external
URLs are silently rejected and a tracing::warn! is emitted.
Trait Implementations§
Source§impl Clone for ActionError
impl Clone for ActionError
Source§fn clone(&self) -> ActionError
fn clone(&self) -> ActionError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ActionError
impl Debug for ActionError
Source§impl Display for ActionError
impl Display for ActionError
Source§impl Error for ActionError
impl Error for ActionError
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<&'static str> for ActionError
impl From<&'static str> for ActionError
Source§impl From<DbErr> for ActionError
impl From<DbErr> for ActionError
Source§impl From<FrameworkError> for ActionError
impl From<FrameworkError> for ActionError
Source§fn from(err: FrameworkError) -> Self
fn from(err: FrameworkError) -> Self
Auto Trait Implementations§
impl Freeze for ActionError
impl RefUnwindSafe for ActionError
impl Send for ActionError
impl Sync for ActionError
impl Unpin for ActionError
impl UnsafeUnpin for ActionError
impl UnwindSafe for ActionError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<E> IntoActionError for Ewhere
E: Display,
impl<E> IntoActionError for Ewhere
E: Display,
Source§fn into_action_error(self) -> ActionError
fn into_action_error(self) -> ActionError
ActionError.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 moreimpl<T> OrderedContainer<T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.