Type Alias rocket::request::FormError

source ·
pub type FormError<'f> = FormDataError<'f, FormParseError<'f>>;
Expand description

Alias to the type of form errors returned by the FromData implementations of Form<T> where the FromForm implementation for T was derived.

This alias is particularly useful when “catching” form errors in routes.


use rocket::request::{Form, FormError, FormDataError};

struct Input {
    value: String,

#[post("/", data = "<sink>")]
fn submit(sink: Result<Form<Input>, FormError>) -> String {
    match sink {
        Ok(form) => form.into_inner().value,
        Err(FormDataError::Io(_)) => "I/O error".into(),
        Err(FormDataError::Malformed(f)) | Err(FormDataError::Parse(_, f)) => {
            format!("invalid form input: {}", f)

Aliased Type§

enum FormError<'f> {
    Malformed(&'f str),
    Parse(FormParseError<'f>, &'f str),




An I/O error occurred while reading reading the data stream. This can also mean that the form contained invalid UTF-8.


Malformed(&'f str)

The form string (in .0) is malformed and was unable to be parsed as HTTP application/x-www-form-urlencoded data.


Parse(FormParseError<'f>, &'f str)

The form string (in .1) failed to parse as the intended structure. The error type in .0 contains further details.