Enum arc_reactor::core::JsonError [−][src]
pub enum JsonError { None, Err(Error), }
The error returned by Request::json()
.
From<JsonError>
is implemented for Response
so you can use the ?
to unwrap or return an early response
#![feature(proc_macro, generators, specialization, proc_macro_non_items)] extern crate arc_reactor; extern crate futures_await as futures; extern crate serde; #[macro_use] extern crate serde_derive; use arc_reactor::prelude::*; #[derive(Serialize, Deserialize)] struct User { name: String } #[service] fn UserService(req: Request, res: Response) { let User { name } = req.json()?; // will return an error response with the // json '{ "error": "Json was empty" }' if JsonError::None // or '{ "error": "{serde error}" }' if it failed to deserialize. Ok(res) }
Variants
None
This error can occur if
- The client, didn't include "content-type: application/json" in the request headers 2. The body parser wasn't mounted as a middleware on this route, directly or indirectly.
Err(Error)
The error reported by serde, when deserialization of the request body fails.