protected ExchangeException handleError(Exception exception) { if (exception != null && exception.getMessage() != null) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else if (exception.getMessage().contains("The system is currently overloaded")) { return new SystemOverloadException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } return new ExchangeException(exception); }
protected RuntimeException handleError(BitcoindeException exception) { if (exception.getMessage().contains("Insufficient credits")) { return new RateLimitExceededException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } }
public static ExchangeException adapt(BitfinexException e) { String message = e.getMessage(); if (StringUtils.isEmpty(message)) { return new ExchangeException(e); } if (message.toLowerCase().contains("unknown symbol")) { return new CurrencyPairNotValidException(message, e); } else if (message.toLowerCase().contains("not enough exchange balance")) { return new FundsExceededException(message, e); } else if (message.toUpperCase().contains("ERR_RATE_LIMIT")) { return new RateLimitExceededException(e); } else if (message.toLowerCase().contains("nonce")) { return new NonceException(e); } return new ExchangeException(message, e); } }
protected ExchangeException handleError(BitflyerException exception) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected ExchangeException handleError(CoinbaseProException exception) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected ExchangeException handleError(CryptonitException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected ExchangeException handleError(BitstampException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(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); } else if ("EOrder:Insufficient funds".equals(error)) { throw new FundsExceededException(error); } if ("EAPI:Rate limit exceeded".equals(error)) { throw new RateLimitExceededException(error); } throw new ExchangeException(Arrays.toString(errors)); } return krakenResult.getResult(); }
protected ExchangeException handleError(Exception exception) { if (exception != null && exception.getMessage() != null) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else if (exception.getMessage().contains("The system is currently overloaded")) { return new SystemOverloadException(exception); } else { return new ExchangeException(exception.getMessage(), exception); } } return new ExchangeException(exception); }
public static ExchangeException adapt(BitfinexException e) { String message = e.getMessage(); if (StringUtils.isEmpty(message)) { return new ExchangeException(e); } if (message.toLowerCase().contains("unknown symbol")) { return new CurrencyPairNotValidException(message, e); } else if (message.toLowerCase().contains("not enough exchange balance")) { return new FundsExceededException(message, e); } else if (message.toUpperCase().contains("ERR_RATE_LIMIT")) { return new RateLimitExceededException(e); } else if (message.toLowerCase().contains("nonce")) { return new NonceException(e); } return new ExchangeException(message, e); } }
protected ExchangeException handleError(BitflyerException exception) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }
protected ExchangeException handleError(GDAXException exception) { if (exception.getMessage().contains("Insufficient")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Rate limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(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); } else if ("EOrder:Insufficient funds".equals(error)) { throw new FundsExceededException(error); } if ("EAPI:Rate limit exceeded".equals(error)) { throw new RateLimitExceededException(error); } throw new ExchangeException(Arrays.toString(errors)); } return krakenResult.getResult(); }
protected ExchangeException handleError(BitstampException exception) { if (exception.getMessage().contains("You can only buy")) { return new FundsExceededException(exception); } else if (exception.getMessage().contains("Invalid limit exceeded")) { return new RateLimitExceededException(exception); } else if (exception.getMessage().contains("Invalid nonce")) { return new NonceException(exception.getMessage()); } else if (exception.getMessage().contains("Internal server error")) { return new InternalServerException(exception); } else { return new ExchangeException(exception); } } }