aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-09-13 20:44:53 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-09-15 20:14:48 +0800
commitc0a14a4a4110f3fedea6624376eae4c86c02cda8 (patch)
treeaed291181f688628d18d2f330b3f6e30dec8a354 /packages
parent8d6132736bfd57d08448cbde538c13072df80256 (diff)
downloaddexon-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
Diffstat (limited to 'packages')
-rw-r--r--packages/forwarder-helper/src/forwarder_helper_factory.ts13
-rw-r--r--packages/forwarder-helper/src/types.ts1
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 {