diff options
author | Steve Klebanoff <steve@0xproject.com> | 2018-12-04 06:24:58 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-04 06:24:58 +0800 |
commit | 50df67e7511460f051f91785bb4384485077ef60 (patch) | |
tree | 3caa4fac28a2af99e7e7d0beff7a661d26f8665e /packages/instant/src/util/asset.ts | |
parent | f076cdb8329693e9d7351ec88d2ac01ad42a2a3a (diff) | |
parent | 91b0fd951708b0fff0733c2e1eed45a403f3cc73 (diff) | |
download | dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.gz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.bz2 dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.lz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.xz dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.tar.zst dexon-sol-tools-50df67e7511460f051f91785bb4384485077ef60.zip |
Merge pull request #1295 from 0xProject/feature/instant/rollbar-env
[instant] Rollbar
Diffstat (limited to 'packages/instant/src/util/asset.ts')
-rw-r--r-- | packages/instant/src/util/asset.ts | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/instant/src/util/asset.ts b/packages/instant/src/util/asset.ts index 40560d3eb..08f3642e3 100644 --- a/packages/instant/src/util/asset.ts +++ b/packages/instant/src/util/asset.ts @@ -1,3 +1,4 @@ +import { AssetBuyerError } from '@0x/asset-buyer'; import { AssetProxyId, ObjectMap } from '@0x/types'; import * as _ from 'lodash'; @@ -106,4 +107,20 @@ export const assetUtils = { ); return _.compact(erc20sOrUndefined); }, + assetBuyerErrorMessage: (asset: ERC20Asset, error: Error): string | undefined => { + if (error.message === AssetBuyerError.InsufficientAssetLiquidity) { + const assetName = assetUtils.bestNameForAsset(asset, 'of this asset'); + return `Not enough ${assetName} available`; + } else if (error.message === AssetBuyerError.InsufficientZrxLiquidity) { + return 'Not enough ZRX available'; + } else if ( + error.message === AssetBuyerError.StandardRelayerApiError || + error.message.startsWith(AssetBuyerError.AssetUnavailable) + ) { + const assetName = assetUtils.bestNameForAsset(asset, 'This asset'); + return `${assetName} is currently unavailable`; + } + + return undefined; + }, }; |