Type Definition rocket::request::FormError [−][src]
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.
Example
use rocket::request::{Form, FormError, FormDataError};
#[derive(FromForm)]
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)
}
}
}