-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[do-not-merge] Deserialize endpoint errors #2443
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
@Safe String errorCode, | ||
@Safe String errorName, | ||
@Safe String errorInstanceId, | ||
@Safe String arg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- can put the args into a separate record which includes matches the
parameters
map for deserialization so we don't need a custom deserializer. - let's annotate each of the parameter fields with a
@JsonProperty
...c/test/java/com/palantir/conjure/java/dialogue/serde/EndpointErrorsConjureBodySerDeTest.java
Outdated
Show resolved
Hide resolved
dialogue-serde/src/main/java/com/palantir/conjure/java/dialogue/serde/ConjureBodySerDe.java
Outdated
Show resolved
Hide resolved
6081541
to
74008d5
Compare
74008d5
to
a46dd8b
Compare
@@ -67,31 +75,49 @@ final class ConjureBodySerDe implements BodySerDe { | |||
*/ | |||
ConjureBodySerDe( | |||
List<WeightedEncoding> rawEncodings, | |||
ErrorDecoder errorDecoder, | |||
ErrorDecoder _errorDecoder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to pass this in. DefaultConjureRuntime
is the public API where this ctor is created, and it passes in a hardcoded ErrorDecoder.INSTANCE
.
a46dd8b
to
c6dfe0c
Compare
errorDecoder = mock(ErrorDecoder.class); | ||
when(errorDecoder.isError(response)).thenReturn(true); | ||
when(errorDecoder.decode(response)).thenReturn(new RemoteException(serialized, 400)); | ||
TestResponse response = TestResponse.withBody( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to have an "e2e" test where the error decoder is actually called (instead of mocked) - to validate that replacing the EncodingDeserializerRegistry
with EncodingDeserializerForEndpointRegistry
doesn't introduce a regression.
I will also port over the tests from ErrorDecoderTest
to test the new EndpointErrorDecoder
@@ -18,6 +18,7 @@ | |||
|
|||
import com.palantir.dialogue.Response; | |||
|
|||
// TODO(pm): use the new EndpointErrorDecoder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace impl in ErrorDecoder
to delegate to the empty-map initialized EndpointErrorDecoder
Before this PR
This is a prototype PR and should not be merged.
We'd like to support the a new method in
BodySerDe
that allows the creation of deserializers given an expected result type, and a set of expected error types.A ConjureError is serialized and sent by servers. Dialogue deserializes the errors to a
SerializableError
which loses the type information of the parameters. By providing the type information of the parameters, Dialogue can deserialize the receivedConjureError
into the well-typed objects (instead of Strings).After this PR
==COMMIT_MSG==
==COMMIT_MSG==
Possible downsides?