In the context of authentication, I use existing jsonrpc functionality to propagate an exception to the client.
So the application throws org.json.rpc.commons.JsonRpcRemoteException with an application-defined result code value.
jsonrpc takes action in
JsonRpcExecutor#execute(JsonRpcServerTransport transport)
try {
JsonElement result = executeMethod(methodName, params);
resp.add("result", result);
} catch (Throwable t) {
LOG.warn("exception occured while executing : " + methodName, t);// #### here
if (t instanceof JsonRpcRemoteException) {
sendError(transport, resp, (JsonRpcRemoteException) t);
return;
}
errorCode = JsonRpcErrorCodes.getServerError(1);
errorMessage = t.getMessage();
errorData = getStackTrace(t);
sendError(transport, resp, errorCode, errorMessage, errorData);
return;
}
It prints a warning message in the log.
Depending on the severity of the abnormal condition, this message may need to be logged as an error, as a warning, or not logged at all. Currently a NullPointerException is converted into a warning.
Can this be improved? Perhaps JsonRpcRemoteException could have a constructor parameter for the logging level so that the application can control the logging behavior?
In the context of authentication, I use existing jsonrpc functionality to propagate an exception to the client.
So the application throws org.json.rpc.commons.JsonRpcRemoteException with an application-defined result code value.
jsonrpc takes action in
JsonRpcExecutor#execute(JsonRpcServerTransport transport)
It prints a warning message in the log.
Depending on the severity of the abnormal condition, this message may need to be logged as an error, as a warning, or not logged at all. Currently a NullPointerException is converted into a warning.
Can this be improved? Perhaps JsonRpcRemoteException could have a constructor parameter for the logging level so that the application can control the logging behavior?