protected RuntimeException handleException(HitbtcException exception) { String message = exception.getMessage(); if ("Nonce has been used".equals(message)) { return new NonceException(message); } return new ExchangeException(message); } }
protected RuntimeException handleHttpError(HttpStatusIOException exception) throws IOException { if (exception.getHttpStatusCode() == 304) { return new NonceException(exception.getHttpBody()); } else { throw exception; } }
protected <R> R checkResult(KrakenResult<R> krakenResult) { if (!krakenResult.isSuccess()) { String[] errors = krakenResult.getError(); if (errors.length == 0) { throw new ExchangeException("Missing error message"); } String error = errors[0]; if ("EAPI:Invalid nonce".equals(error)) { throw new NonceException(error); } else if ("EGeneral:Temporary lockout".equals(error)) { throw new FrequencyLimitExceededException(error); } throw new ExchangeException(Arrays.toString(errors)); } return krakenResult.getResult(); }
protected void checkResult(BTCEReturn<?> result) { String error = result.getError(); if (!result.isSuccess()) { if (error != null) { if (error.startsWith(ERR_MSG_NONCE)) { throw new NonceException(error); } else if (error.startsWith(ERR_MSG_FUNDS)) { throw new FundsExceededException(error); } } throw new ExchangeException(error); } else if (result.getReturnValue() == null) { throw new ExchangeException("Didn't receive any return value. Message: " + error); } else if (error != null) { throw new ExchangeException(error); } }