Show the errored path on JsonDataError - #1371
Conversation
davidpdrsn
left a comment
There was a problem hiding this comment.
Thanks! I think it looks good.
Worth nothing that this changes the inner error of a JsonRejection from serde_json::Error to serde_path_to_error::Error<serde_json::Error>. Thats not considered a breaking change but I think we should mention it in the changelog regardless.
|
|
||
| assert_eq!(res.status(), StatusCode::UNPROCESSABLE_ENTITY); | ||
| let body_text = res.text().await; | ||
| assert!(body_text.contains("b[0]"), "body: {:?}", body_text); |
There was a problem hiding this comment.
Wanna change this to match on the whole text, instead of using contains? Then its easier to see what the final result actually is.
|
I wonder whether this has significant performance implications for parsing. Maybe it should only be part of axum-extra (for now) if that is the case? |
|
Good point. I ran the benchmark:
This branch is faster, which is odd so might just be noise and no loss of performance. |
|
That's the |
Yes |
16b6672 to
4d2efa1
Compare
|
@davidpdrsn I amended the commit. Could you take a look again? |
Previously, it was difficult to find out the path in the deep JSON tree at which a deserialization error occurred. This patch makes an error message to contain the errored path. In order to find out the path, I added serde_path_to_error, a new optional dependency. Co-authored-by: Lee Dogeon <dev.moreal@gmail.com>
4d2efa1 to
8fe7cf5
Compare
|
@davidpdrsn Fixed the changelogs! |
Motivation
Previously, it was difficult to find out the path in the deep JSON tree at which a deserialization error occurred.
Solution
This patch makes an error message to contain the errored path. In order to find out the path, I added serde_path_to_error, a new optional dependency.