use of io.nuls.kernel.model.ErrorData in project nuls by nuls-io.
the class RpcServerFilter method toResponse.
@Override
public Response toResponse(Exception e) {
// System.out.println("---------------" + request.getRequestURI());
Log.error("RequestURI is " + request.getRequestURI(), e);
RpcClientResult result;
if (e instanceof NulsException) {
NulsException exception = (NulsException) e;
result = new RpcClientResult(false, exception.getErrorCode());
} else if (e instanceof NulsRuntimeException) {
NulsRuntimeException exception = (NulsRuntimeException) e;
result = new RpcClientResult(false, new ErrorData(exception.getCode(), exception.getMessage()));
} else {
result = Result.getFailed().setMsg(e.getMessage()).toRpcClientResult();
}
return Response.ok(result, MediaType.APPLICATION_JSON).build();
}
Aggregations