/** * Gets the error. * * @return the error */ public JSONRPCException getError() { if (resp.has(ERROR)) { final JsonNode error = resp.get(ERROR); try { return new JSONRPCException(error); } catch (JsonProcessingException e) { LOG.log(Level.WARNING, "Couldn't parse error", e); } } return null; }
switch (code) { case UNKNOWN_ERROR: setCode(-32000); setMessage("Unknown error"); break; case PARSE_ERROR: setCode(-32700); setMessage("Parse error"); break; case INVALID_REQUEST: setCode(-32600); setMessage("Invalid request"); break; case REMOTE_EXCEPTION: setCode(-32500); setMessage("Remote application error"); break; case METHOD_NOT_FOUND: setCode(-32601); setMessage("Method not found"); break; case INVALID_PARAMS: setCode(-32602); setMessage("Invalid params"); break; case INTERNAL_ERROR: setCode(-32603); setMessage("Internal error"); break;
/** * Instantiates a new jSONRPC exception. * * @param error * the error */ public JSONRPCException(final JSONRPCException error) { super(error); if (error != null) { setCode(error.getCode()); setMessage(error.getMessage()); if (error.hasData()) { setData(error.getData()); } } else { init(CODE.UNKNOWN_ERROR, null, null); } }
final AnnotatedMethod annotatedMethod = tuple.getMethod(); if (!isAvailable(annotatedMethod, realDest, requestParams, auth)) { throw new JSONRPCException( JSONRPCException.CODE.METHOD_NOT_FOUND, "Method '" + request, cause); final JSONRPCException jsonError = new JSONRPCException( JSONRPCException.CODE.INTERNAL_ERROR, getMessage(cause), cause); jsonError.setData(cause); resp.setError(jsonError); } else { + request, err); final JSONRPCException jsonError = new JSONRPCException( JSONRPCException.CODE.INTERNAL_ERROR, getMessage(err), err); jsonError.setData(err); resp.setError(jsonError);
/** * Throw the root cause is available. * * @throws Throwable * the throwable */ @JsonIgnore public void throwRootCause() throws Throwable { if (getRootCause() != null) { throw getRootCause(); } } }
@Override public String toString() { return this.getClass().getName() + ": " + (remote ? "(Remote stackTrace) " : "") + getLocalizedMessage(); }
/** * Gets the root cause. * * @return the root cause */ @JsonIgnore public Throwable getRootCause() { final List<Throwable> list = getThrowableList(); return list.size() < 2 ? null : (Throwable) list.get(list.size() - 1); }
/** * Sets the error. * * @param error * the new error */ public void setError(final JSONRPCException error) { if (error != null) { resp.set(ERROR, error.getJsonNode()); setResult(null); } else { if (resp.has(ERROR)) { resp.remove(ERROR); } } }
throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Request is null"); throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Value of member 'jsonrpc' is not equal to '2.0'"); throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Member 'method' missing in request"); throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Member 'method' is no String"); throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Member 'params' is no ObjectNode");
throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Response is null"); throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Value of member 'jsonrpc' must be '2.0'"); && !jsonNode.get(ERROR).isNull(); if (hasError && !(jsonNode.get(ERROR).isObject())) { throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Member 'error' is no ObjectNode"); if (hasError) { try { error = new JSONRPCException(jsonNode.get(ERROR)); } catch (JsonProcessingException e) { throw new JSONRPCException(JSONRPCException.CODE.INVALID_REQUEST, "Member 'error' is no a real JSONRPCException.");
sender.call(receiverUrl, method, args, callback); } catch (final IOException e) { throw new JSONRPCException(CODE.REMOTE_EXCEPTION, e .getLocalizedMessage(), e); method.getGenericReturnType()); } catch (final Exception e) { throw new JSONRPCException( CODE.REMOTE_EXCEPTION, e .getLocalizedMessage(), e);
asyncCallback.onSuccess(res); } catch (final ClassCastException cce) { asyncCallback.onFailure(new JSONRPCException( "Incorrect return type received for JSON-RPC call:" + request.getMethod(), cce));
final JSONRPCException jsonError = new JSONRPCException( JSONRPCException.CODE.INTERNAL_ERROR, e.getMessage(), e); LOG.log(Level.WARNING, "Exception in receiving message", jsonError);
@Override public void onSuccess(final JSONResponse response) { final Exception err = response.getError(); if (err != null) { asyncCallback.onFailure(err); } if (asyncCallback.getType() != null && !asyncCallback.getType().getJavaType().getRawClass() .equals(Void.class)) { try { final T res = asyncCallback.getType().inject( response.getResult()); asyncCallback.onSuccess(res); } catch (final ClassCastException cce) { asyncCallback.onFailure(new JSONRPCException( "Incorrect return type received for JSON-RPC call:" + request.getMethod(), cce)); } } else { asyncCallback.onSuccess(null); } }