aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/src/errors.ts
blob: 68e9a684bb15aa1d26cf007fc9e961f709408f3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { BigNumber } from '@0x/utils';

import { AssetBuyerError } from './types';

/**
 * Error class representing insufficient asset liquidity
 */
export class InsufficientAssetLiquidityError extends Error {
    /**
     * The amount availabe to fill (in base units) factoring in slippage.
     */
    public amountAvailableToFill?: BigNumber;
    /**
     * @param amountAvailableToFill The amount availabe to fill (in base units) factoring in slippage
     */
    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);
    }
}