handle other errors

This commit is contained in:
Steve Klebanoff 2018-10-17 14:02:39 -07:00
parent 2b495a7935
commit ae4f1a093a

View File

@ -28,11 +28,22 @@ class ErrorFlasher {
}
const humanReadableMessageForError = (error: Error, assetData?: string): string | undefined => {
if (error.message === AssetBuyerError.InsufficientAssetLiquidity) {
const hasInsufficientLiquidity =
error.message === AssetBuyerError.InsufficientAssetLiquidity ||
error.message === AssetBuyerError.InsufficientZrxLiquidity;
if (hasInsufficientLiquidity) {
const assetName = assetDataUtil.bestNameForAsset(assetData, 'of this asset');
return `Not enough ${assetName} available`;
}
if (
error.message === AssetBuyerError.StandardRelayerApiError ||
error.message.startsWith(AssetBuyerError.AssetUnavailable)
) {
const assetName = assetDataUtil.bestNameForAsset(assetData, 'This asset');
return `${assetName} is currently unavailable`;
}
return undefined;
};