Skip to content

Commit

Permalink
Unwrap the actual failure from JsonRPC if it's wrapped
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartisk committed Feb 22, 2024
1 parent 44d5b77 commit a0c8165
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.devui.runtime.comms;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -206,7 +207,19 @@ private void route(JsonRpcRequest jsonRpcRequest, ServerWebSocket s) {
MessageType.Response);
}
}, failure -> {
codec.writeErrorResponse(s, jsonRpcRequest.getId(), jsonRpcMethodName, failure);
Throwable actualFailure;
// If the jsonrpc method is actually
// synchronous, the failure is wrapped in an
// InvocationTargetException, so unwrap it here
if (failure instanceof InvocationTargetException f) {
actualFailure = f.getTargetException();
} else if (failure.getCause() != null
&& failure.getCause() instanceof InvocationTargetException f) {
actualFailure = f.getTargetException();
} else {
actualFailure = failure;
}
codec.writeErrorResponse(s, jsonRpcRequest.getId(), jsonRpcMethodName, actualFailure);
});
}
} else {
Expand Down

0 comments on commit a0c8165

Please sign in to comment.