aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/errors.ts
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-15 07:18:20 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-15 07:34:45 +0800
commit69054d85e80f9e41200015a9b0eef2a9fe00f439 (patch)
treec8296279c2f51518940cc772a26e626f5931e9de /packages/asset-buyer/src/errors.ts
parent3e596f6a8c211eb39917cfd2a9a68a6facf2c904 (diff)
downloaddexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.gz
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.bz2
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.lz
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.xz
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.tar.zst
dexon-sol-tools-69054d85e80f9e41200015a9b0eef2a9fe00f439.zip
Only send in amountAvailableToFill if it's a non-zero amount, add additional tests and nest, and put error into its own file
Diffstat (limited to 'packages/asset-buyer/src/errors.ts')
-rw-r--r--packages/asset-buyer/src/errors.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/packages/asset-buyer/src/errors.ts b/packages/asset-buyer/src/errors.ts
new file mode 100644
index 000000000..ef05a5d0a
--- /dev/null
+++ b/packages/asset-buyer/src/errors.ts
@@ -0,0 +1,16 @@
+import { BigNumber } from '@0x/utils';
+
+import { AssetBuyerError } from './types';
+
+/**
+ * Error class representing insufficient asset liquidity
+ */
+export class InsufficientAssetLiquidityError extends Error {
+ public amountAvailableToFill?: BigNumber;
+ constructor(amountAvailableToFill?: BigNumber) {
+ super(AssetBuyerError.InsufficientAssetLiquidity);
+ this.amountAvailableToFill = amountAvailableToFill;
+ // Setting prototype so instanceof works. See https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
+ Object.setPrototypeOf(this, InsufficientAssetLiquidityError.prototype);
+ }
+}