diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-09-13 20:44:53 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-09-15 20:14:48 +0800 |
commit | c0a14a4a4110f3fedea6624376eae4c86c02cda8 (patch) | |
tree | aed291181f688628d18d2f330b3f6e30dec8a354 | |
parent | 8d6132736bfd57d08448cbde538c13072df80256 (diff) | |
download | dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar.gz dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar.bz2 dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar.lz dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar.xz dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.tar.zst dexon-sol-tools-c0a14a4a4110f3fedea6624376eae4c86c02cda8.zip |
Catch standard relayer api errors
-rw-r--r-- | packages/forwarder-helper/src/forwarder_helper_factory.ts | 13 | ||||
-rw-r--r-- | packages/forwarder-helper/src/types.ts | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/packages/forwarder-helper/src/forwarder_helper_factory.ts b/packages/forwarder-helper/src/forwarder_helper_factory.ts index ab8eaeeaf..be38f2bd5 100644 --- a/packages/forwarder-helper/src/forwarder_helper_factory.ts +++ b/packages/forwarder-helper/src/forwarder_helper_factory.ts @@ -79,10 +79,15 @@ export const forwarderHelperFactory = { { baseAssetData: zrxTokenAssetData, quoteAssetData: etherTokenAssetData }, ]; const requestOpts = { networkId }; - // TODO: try catch these requests and throw a more domain specific error - const [makerAssetOrderbook, zrxOrderbook] = await Promise.all( - _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), - ); + let makerAssetOrderbook: OrderbookResponse; + let zrxOrderbook: OrderbookResponse; + try { + [makerAssetOrderbook, zrxOrderbook] = await Promise.all( + _.map(orderbookRequests, request => sraClient.getOrderbookAsync(request, requestOpts)), + ); + } catch (err) { + throw new Error(ForwarderHelperFactoryError.StandardRelayerApiError); + } // validate orders and find remaining fillable from on chain state or sra api let ordersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; let feeOrdersAndRemainingFillableMakerAssetAmounts: OrdersAndRemainingFillableMakerAssetAmounts; diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts index 5a8439257..a7f02ff8d 100644 --- a/packages/forwarder-helper/src/types.ts +++ b/packages/forwarder-helper/src/types.ts @@ -4,6 +4,7 @@ import { BigNumber } from '@0xproject/utils'; export enum ForwarderHelperFactoryError { NoEtherTokenContractFound = 'NO_ETHER_TOKEN_CONTRACT_FOUND', NoZrxTokenContractFound = 'NO_ZRX_TOKEN_CONTRACT_FOUND', + StandardRelayerApiError = 'STANDARD_RELAYER_API_ERROR', } export interface ForwarderHelper { |