Skip to content

Access to rejected path parameter #556

Answered by pnehrer
pnehrer asked this question in Q&A
Discussion options

You must be logged in to vote

Certainly, suppose I have a few path parameters: /prefix/:param1/infix/:param2 and a handler that accepts them:

async fn handle_request(Path((param1, param2)): Path<(SomeDeserializableType, String)>) {
    ...
}

To handle parse errors myself, I can wrap the extractor in Result<Path<...>, PathParamsRejection> but even if do, PathParamsRejection doesn't really tell me which parameter failed and why -- I mean there's a description of the error, but the error itself doesn't give more details like e.g., serde_json::de::Error would.

E.g., I would like to get the name of the failed parameter (alone, not in a formatted description) and the expected type.

Or maybe I'm not looking in the right place?

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@davidpdrsn
Comment options

Answer selected by davidpdrsn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants