Can't handle ParseError and other param errors #1026
Unanswered
Mahoo12138
asked this question in
Q&A
Replies: 1 comment
-
same question. #[derive(Debug, Deserialize, Serialize)]
struct User {
id: i64,
}
#[handler]
async fn json_req(user: JsonBody<User>, res: &mut Response) {
println!("req json id: {:?}", user.id);
let user2 = User { id: user.id };
res.render(Json(user2))
} when parse json body, how to cather error then return json response like: {
"code": -2,
"msg": "parse details error"
}
and apply to anther post, get request |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a project created with salvo-cli:
Beta Was this translation helpful? Give feedback.
All reactions