Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About @ jsonrpcerrors and @ jsonrpcclientexception #277

Open
qq454549798 opened this issue Oct 22, 2021 · 0 comments
Open

About @ jsonrpcerrors and @ jsonrpcclientexception #277

qq454549798 opened this issue Oct 22, 2021 · 0 comments

Comments

@qq454549798
Copy link

In the use of jsonrpc exceptions, it is troublesome to annotate @ jsonrpcerrors. If there are different exceptions in a method, multiple items need to be configured in @ jsonrpcerrors.

In the exception handling class defaulterrorresolver, it is recommended to adjust the method resolveerror to:

public JsonError resolveError(Throwable t, Method method, List arguments) {

//Add an exception judgment and bring in the error code

if (t instanceof JsonRpcClientException) {

JsonRpcClientException rpcException = ((JsonRpcClientException) t);

return new JsonError(rpcException.getCode(), rpcException.getMessage(), new ErrorData(t.getClass().getName(), rpcException.getMessage()));

}

return new JsonError(ERROR_NOT_HANDLED.code, t.getMessage(), new ErrorData(t.getClass().getName(), t.getMessage()));

}

In this way, when trying to catch, you can directly handle exceptions through new jsonrpcclientexception (code, message, jsonnode).

If you don't rewrite the code here, the code here can't be customized. It's always 36001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant