Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning useful error message back to client when request JSON data can't be deserialized? #1387

Closed
ghost opened this issue Jul 22, 2020 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@ghost
Copy link

ghost commented Jul 22, 2020

Rocket version: 0.4.5

Given a route like the one below that takes a Json request body:

#[post("/", format = "json", data = "<data>")]
fn my_route(data: Json<MyData>) -> ...

If the user submits an invalid request body to an endpoint like the one listed below it returns a generic 422 error page. I'd like to return some more useful information, such as the text of the serde deserialization error to give the user a hint as to what is wrong with their request. I looked at catchers guide to see if there's a way to get at the error generated processing the request but can't figure out how to do this.

@ghost ghost changed the title Returning useful error message back to client when request data can't be deserialized? Returning useful error message back to client when request JSON data can't be deserialized? Jul 22, 2020
@ghost ghost closed this as completed Jul 22, 2020
@ghost ghost reopened this Jul 22, 2020
@ghost ghost closed this as completed Jul 23, 2020
@ghost ghost reopened this Jul 23, 2020
@SergioBenitez
Copy link
Member

This is either #749 or #1232. In any case, see #1232 (comment) for what you can do today.

@SergioBenitez SergioBenitez added the duplicate This issue or pull request already exists label Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

1 participant