public BitcoinRPCException(BitcoinRPCError error) { super(error.getMessage()); this.rpcError = error; }
rpcError = new BitcoinRPCError(error);
@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }
public BitcoinRPCException(BitcoinRPCError error) { super(error.getMessage()); this.rpcError = error; }
@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }
public BitcoinRPCException(BitcoinRPCError error) { super(error.getMessage()); this.rpcError = error; }
rpcError = new BitcoinRPCError(error);
private String pageError(VelocityContext context, Throwable th) { String errmsg = th.getMessage(); if (errmsg == null || errmsg.length() == 0) errmsg = th.toString(); if (th instanceof BitcoinRPCException) { errmsg = ((BitcoinRPCException) th).getRPCError().getMessage(); errmsg = "Blockchain not available: " + errmsg; } context.put("errmsg", errmsg); return "templates/portal-error.vm"; }
rpcError = new BitcoinRPCError(error);
@SuppressWarnings("rawtypes") public Object loadResponse(InputStream in, Object expectedID, boolean close) throws IOException, GenericRpcException { try { String r = new String(loadStream(in, close), QUERY_CHARSET); logger.log(Level.FINE, "Bitcoin JSON-RPC response:\n{0}", r); try { Map response = (Map) JSON.parse(r); if (!expectedID.equals(response.get("id"))) throw new BitcoinRPCException("Wrong response ID (expected: " + String.valueOf(expectedID) + ", response: " + response.get("id") + ")"); if (response.get("error") != null) throw new BitcoinRPCException(new BitcoinRPCError((Map)response.get("error"))); return response.get("result"); } catch (ClassCastException ex) { throw new BitcoinRPCException("Invalid server response format (data: \"" + r + "\")"); } } finally { if (close) in.close(); } }