conjure-rust icon indicating copy to clipboard operation
conjure-rust copied to clipboard

Move error decoding out of Client, support custom decoders

Open sfackler opened this issue 1 year ago • 4 comments

a la https://github.com/palantir/dialogue/blob/156b8d91f36e68fbad857fcc8fe0fa0ca57a90d8/dialogue-annotations/src/main/java/com/palantir/dialogue/annotations/ErrorDecoder.java

sfackler avatar Dec 01 '23 14:12 sfackler

It seems to me like our DeserializeResponse and AsyncDeserializeResponse already force custom error decoding by returning a Result in deserialize. I guess one small improvement would be to make the error type generic instead of a conjure error if we wanted to handle arbitrary types of errors?

TheKeveloper avatar Dec 15 '23 22:12 TheKeveloper

The issue here is that the Client is currently internally responsible for converting all non-2xx responses into Errs. If we moved or disabled that we'd be able to allow the caller to control that logic more directly. I'm not so concerned about the Rust error type.

sfackler avatar Jan 02 '24 14:01 sfackler

Ah I think I see. So we'd want to restrict the errors returned by Client to be just transport errors, then update the response deserializer implementations to decode the raw response status code and return an error if one should be returned. Then we'd want to update the client implementation in conjure-rust-runtime to avoid parsing the status code in an error and instead just let that be handled downstream.

Is that generally what you were thinking?

TheKeveloper avatar Jan 02 '24 21:01 TheKeveloper

Yep, though I think it'll take some design work to figure out how it should interact with Conjure's internal retry logic.

sfackler avatar Jan 02 '24 22:01 sfackler