Repository navigation
Add ability to make error as a value. - #3559
Conversation
445782b to
ea9a37e
Compare
ea9a37e to
cb297c8
Compare
|
Thanks for this — the design is sound and you clearly thought about Blocking1. The new branch at if (!shouldDecodeResponseBody) {
...
return decodeErrorResponseBody(response, error); // decoder called with void.class
}
if (isVoidType(returnType) && !decodeVoid) { // :120 — success path onlyWith Fold 2. The flag implicitly stops throwing on 404, 204 and bodiless errors. With the stock builder (no
3. No README. New public functionality needs documenting — 4. Test hygiene. Strongly recommended
Other coverage gapsBeyond the void case: the One smaller thing: |
velo
left a comment
There was a problem hiding this comment.
Nothing has changed since the review on 09-21, so the blocking items are still open:
voidmethods swallow errors. The new branch runs before the void check. For example, avoidDELETE gets a 500 with a JSON body (JacksonDecoder+decodeErrorResponses()):decode(..., void.class)returns null and the call returns normally.- Default decoder turns auth failures into values.
StringDecoder.canDecodereturns true for 404, 204, a null body, or aStringreturn type. So with the stock builder, a 401 with no body returnsnullinstead of throwingUnauthorized. - Unbounded buffering.
bufferBodyreads the whole 4xx/5xx body into memory. The existing path stops atMAX_RESPONSE_BUFFER_SIZE. - Missing tests for the void case, the default decoder, the async path, the decoder that isn't a
PredicatedDecoder, and anErrorDecoderthat returns null. - Still to do: add the README section under
### Error Handling, close theMockWebServer, importOptionalDecoderinstead of writing it in full, and mark the new builder method@Experimental.
|
Hi velo, I'm planning to do it today... |
Signed-off-by: Marvin Froeder <velo.br@gmail.com>
…r async, null ErrorDecoder and non-predicated decoders; document decodeErrorResponses Signed-off-by: Marvin Froeder <velo.br@gmail.com>
velo
left a comment
There was a problem hiding this comment.
Thanks for the feature! I pushed a follow-up for the open review items: void methods still throw, 404 and empty or bodiless errors still throw (dismiss404 stays the way to opt out of a 404), and the error body is read only up to the existing 8 KB limit. There are tests for the async path, a decoder that isn't predicated, and a null ErrorDecoder. decodeErrorResponses() is marked @experimental, and the README and CHANGELOG are updated.
Solving issue #2944.
Unfortunately for status code 204 and 404, all decoders are implemented to return empty body. I don't know what's the best way to handle this, so I leave it as is (make them keep returning empty body to avoid backward incompatibility). Any guideline to handle this better is much appreciated.
This is my first PR in this repo, do tell me if there is anything need to be fixed. Thanks 🙏