centraldogma
centraldogma copied to clipboard
Unwrap exception in the client
We have pre-defined exceptions and throw them in the client depending on the response the client gets.
For example, if the client gets a shutting down exception message from the server, the client throws ShuttingDownException
.
However, the error message from the server isn't unwrapped so CentralDogmaException
is thrown instead:
com.linecorp.centraldogma.common.CentralDogmaException: unexpected response: [:status=500, ...], {"exception":"java.util.concurrent.CompletionException","message":"com.linecorp.centraldogma.common.ShuttingDownException"}
at com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogma.handleErrorResponse(ArmeriaCentralDogma.java:1135)
at com.linecorp.centraldogma.client.armeria.ArmeriaCentralDogma.normalizeRevision(ArmeriaCentralDogma.java:396)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
at java.base/java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2073)
at com.linecorp.armeria.common.util.UnmodifiableFuture.doComplete(UnmodifiableFuture.java:152)
at com.linecorp.armeria.common.util.UnmodifiableFuture.lambda$wrap$0(UnmodifiableFuture.java:103)
We should unwrap the message and throw the corresponding exception. https://github.com/line/centraldogma/blob/master/client/java-armeria/src/main/java/com/linecorp/centraldogma/client/armeria/ArmeriaCentralDogma.java#L1116-L1135