Unable to pass user defined data object as JsonNode while throw exception
rojanjohnv opened this issue · 1 comments
Hi
I want to throw JsonRpcClientException from server to client with user defined code, message and JsonNode object. Unfortunately I could not receive the data object in jsonrpc error object response. Here am using Annotation @JsonRpcErrors for sending errors. Even if am using direct error resolver facing the same issue.
Interface
@JsonRpcErrors({ @JsonRpcError(exception = JsonRpcClientException.class, code = -32600) })
@JsonRpcMethod(value = "process")
public void process(@JsonRpcParam(value = "request") Request request);
Implementation
public void process(@JsonRpcParam(value = "request") Request request) {
ObjectMapper mapper = new ObjectMapper();
NodeBean data = new NodeBean();
data.setCode(100);
data.setMessage("Test message from error data object");
JsonNode jsonNode = mapper.convertValue(data, JsonNode.class);
throw new JsonRpcClientException( -32600, "Invalid request param", jsonNode);
}
As per my analysis on latest version 1.5.3, I could see, there is no constructor to pass 'data' object to ErrorData class. I dont know my analysis correct or not, or could you please give me an idea about the usage of @JsonRpcErrors.
MultipleErrorResolver.java
return new JsonError(ERROR_NOT_HANDLED.code, t.getMessage(), new ErrorData(t.getClass().getName(), t.getMessage()));
AnnotationsErrorResolver.java
return new JsonError(resolver.code(), message, new ErrorData(resolver.exception().getName(), message));
I have the same question.