diff options
-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 { |