[][src]Type Definition rocket::request::FormError

type FormError<'f> = FormDataError<'f, FormParseError<'f>>;

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)