use of org.aion.rpc.errors.RPCExceptions.RPCException in project aion by aionnetwork.
the class Web3EntryPoint method call.
public String call(String requestString) {
logger.debug("Received request: {}", requestString);
Request request = null;
RpcError err = null;
Integer id = null;
Object resultUnion = null;
Stopwatch stopwatch = null;
if (logger.isDebugEnabled()) {
stopwatch = Stopwatch.createStarted();
}
try {
request = readRequest(requestString);
id = request.id;
if (checkMethod(request.method)) {
resultUnion = RPCServerMethods.execute(request, rpc);
} else {
logger.debug("Request attempted to call a method on a disabled interface: {}", request.method);
err = InvalidRequestRPCException.INSTANCE.getError();
}
} catch (InvalidRequestRPCException e) {
// Don't log this error since it may already be logged elsewhere
err = e.getError();
} catch (RPCException e) {
logger.debug("Request failed due to an RPC exception: {}", e.getMessage());
err = e.getError();
} catch (Exception e) {
logger.error("Call to {} failed.", request == null ? "null" : request.method);
logger.error("Request failed due to an internal error: ", e);
err = new InternalErrorRPCException(e.getClass().getSimpleName() + ":" + e.getMessage()).getError();
// creating an instance of RpcError
}
final String resultString = ResponseConverter.encodeStr(new Response(id, resultUnion, err, VersionType.Version2));
if (stopwatch != null) {
logger.debug("Produced response: {}bytes in <{}>ms", resultString.getBytes().length, stopwatch.elapsed().toMillis());
}
return resultString;
}
Aggregations