aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util/error.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src/util/error.ts')
-rw-r--r--packages/instant/src/util/error.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/packages/instant/src/util/error.ts b/packages/instant/src/util/error.ts
index c9b13ef83..40fd24c7e 100644
--- a/packages/instant/src/util/error.ts
+++ b/packages/instant/src/util/error.ts
@@ -2,7 +2,9 @@ import { AssetBuyerError } from '@0x/asset-buyer';
import { Dispatch } from 'redux';
import { Action, actions } from '../redux/actions';
-import { assetDataUtil } from '../util/asset_data';
+import { Asset } from '../types';
+
+import { assetUtils } from './asset';
class ErrorFlasher {
private _timeoutId?: number;
@@ -27,12 +29,12 @@ class ErrorFlasher {
}
}
-const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => {
+const humanReadableMessageForError = (error: Error, asset?: Asset): string | undefined => {
const hasInsufficientLiquidity =
error.message === AssetBuyerError.InsufficientAssetLiquidity ||
error.message === AssetBuyerError.InsufficientZrxLiquidity;
if (hasInsufficientLiquidity) {
- const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset');
+ const assetName = assetUtils.bestNameForAsset(asset, 'of this asset');
return `Not enough ${assetName} available`;
}
@@ -40,7 +42,7 @@ const humanReadableMessageForError = (error: Error, assetData?: string): string
error.message === AssetBuyerError.StandardRelayerApiError ||
error.message.startsWith(AssetBuyerError.AssetUnavailable)
) {
- const assetName = assetDataUtil.bestNameForAsset(assetData, 'This asset');
+ const assetName = assetUtils.bestNameForAsset(asset, 'This asset');
return `${assetName} is currently unavailable`;
}
@@ -49,10 +51,10 @@ const humanReadableMessageForError = (error: Error, assetData?: string): string
export const errorUtil = {
errorFlasher: new ErrorFlasher(),
- errorDescription: (error?: any, assetData?: string): { icon: string; message: string } => {
+ errorDescription: (error?: any, asset?: Asset): { icon: string; message: string } => {
let bestMessage: string | undefined;
if (error instanceof Error) {
- bestMessage = humanReadableMessageForError(error, assetData);
+ bestMessage = humanReadableMessageForError(error, asset);
}
return {
icon: '😢',