Handle unexpected value in request #1757
Answered
by
SergioBenitez
sagarnayak
asked this question in
Questions
-
If i have this route.
and I provide an age number which is a number out of range from u8 then how do I handle this and send a meaningful message to the user. As of now, I am thinking to create another route that takes a string age and tries to find the error that the user has one and provide a message. |
Beta Was this translation helpful? Give feedback.
Answered by
SergioBenitez
Jul 11, 2021
Replies: 1 comment
-
Use a |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
sagarnayak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use a
Result<u8, &str>
instead of the bareu8
. It will be anErr(&str)
with the original parameter if and when it failedto parse as a
u8
. All of this is discussed in detail in the API docs forFromParam
.