Search in sources :

Example 1 with CryptopiaException

use of org.knowm.xchange.cryptopia.dto.CryptopiaException in project XChange by knowm.

the class CryptopiaTradeService method getTradeHistory.

@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {
    try {
        CurrencyPair currencyPair = null;
        Integer limit = 100;
        if (params instanceof TradeHistoryParamCurrencyPair) {
            currencyPair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
        }
        if (params instanceof TradeHistoryParamLimit) {
            limit = ((TradeHistoryParamLimit) params).getLimit();
        }
        return new UserTrades(tradeHistory(currencyPair, limit), Trades.TradeSortType.SortByTimestamp);
    } catch (CryptopiaException e) {
        throw CryptopiaErrorAdapter.adapt(e);
    }
}
Also used : UserTrades(org.knowm.xchange.dto.trade.UserTrades) CryptopiaException(org.knowm.xchange.cryptopia.dto.CryptopiaException) TradeHistoryParamLimit(org.knowm.xchange.service.trade.params.TradeHistoryParamLimit) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Example 2 with CryptopiaException

use of org.knowm.xchange.cryptopia.dto.CryptopiaException in project XChange by knowm.

the class CryptopiaErrorAdapterTest method adapt_unrecognizedErrorMessage.

@Test
public void adapt_unrecognizedErrorMessage() {
    CryptopiaException e = new CryptopiaException();
    e.setError("Some other error message");
    ExchangeException adapted = CryptopiaErrorAdapter.adapt(e);
    assertThat(adapted).isExactlyInstanceOf(ExchangeException.class);
}
Also used : CryptopiaException(org.knowm.xchange.cryptopia.dto.CryptopiaException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) Test(org.junit.Test)

Example 3 with CryptopiaException

use of org.knowm.xchange.cryptopia.dto.CryptopiaException in project XChange by knowm.

the class CryptopiaErrorAdapterTest method adapt_noErrorMessage.

@Test
public void adapt_noErrorMessage() {
    ExchangeException adapted = CryptopiaErrorAdapter.adapt(new CryptopiaException());
    assertThat(adapted).isExactlyInstanceOf(ExchangeException.class);
}
Also used : CryptopiaException(org.knowm.xchange.cryptopia.dto.CryptopiaException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) Test(org.junit.Test)

Example 4 with CryptopiaException

use of org.knowm.xchange.cryptopia.dto.CryptopiaException in project XChange by knowm.

the class CryptopiaErrorAdapterTest method adapt_wrongMarket.

@Test
public void adapt_wrongMarket() {
    CryptopiaException e = new CryptopiaException();
    e.setError("Market STRG_BTC not found");
    ExchangeException adapted = CryptopiaErrorAdapter.adapt(e);
    assertThat(adapted).isExactlyInstanceOf(CurrencyPairNotValidException.class);
}
Also used : CryptopiaException(org.knowm.xchange.cryptopia.dto.CryptopiaException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) Test(org.junit.Test)

Aggregations

CryptopiaException (org.knowm.xchange.cryptopia.dto.CryptopiaException)4 Test (org.junit.Test)3 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)3 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)1 TradeHistoryParamLimit (org.knowm.xchange.service.trade.params.TradeHistoryParamLimit)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)1