- OnComplete<Object> onComplete = new OnComplete<Object>() {
- @Override
- public void onComplete(Throwable failure, Object reply) throws Throwable {
- if(failure != null) {
- LOG.error("InvokeRpc failed", failure);
-
- RpcResult<CompositeNode> rpcResult;
- if(failure instanceof RpcErrorsException) {
- rpcResult = RpcResultBuilder.<CompositeNode>failed().withRpcErrors(
- ((RpcErrorsException)failure).getRpcErrors()).build();
- } else {
- rpcResult = RpcResultBuilder.<CompositeNode>failed().withError(
- ErrorType.RPC, failure.getMessage(), failure).build();
+ final String message = String.format("Execution of RPC %s failed", rpcMsg.getRpc());
+ Collection<RpcError> errors = ((RpcErrorsException)failure).getRpcErrors();
+ if(errors == null || errors.size() == 0) {
+ errors = Arrays.asList(RpcResultBuilder.newError(ErrorType.RPC, null, message));