requests.ErrorJSON(data any) validator #32
-
Create a validator that checks the status code and if it's bad, attempts to marshal the JSON to the object provided. It would need to still return an error to prevent further handling, but the error could be a sentinel instead of a ResponseError, so it's cheaper. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
Maybe ErrorJSON(data any, statuses …int). |
Beta Was this translation helpful? Give feedback.
-
Yes this is what I was thinking.
Il ven 8 apr 2022, 18:32 Carl Johnson ***@***.***> ha scritto:
… Or maybe
type ErrorJSONError struct {
*ResponseError
Data any
}
Or maybe even generics?
type ErrorJSONError[T any] struct {
*ResponseError
Data T
}
I think this is doable?
—
Reply to this email directly, view it on GitHub
<#32 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEO5JPGBG7CULNHL7PCTDDVEBNRPANCNFSM5LKT3WPA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Just wanted to add a +1 for the ability to parse JSON responses from errors. |
Beta Was this translation helpful? Give feedback.
-
See #63. |
Beta Was this translation helpful? Give feedback.
See #63.