-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.ts
30 lines (26 loc) · 1005 Bytes
/
errors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// see https://stackoverflow.com/a/41102306
const CAN_SET_PROTOTYPE = 'setPrototypeOf' in Object
/**
* Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be
* obtained by sending any amount of input.
*/
export class InsufficientReservesError extends Error {
public readonly isInsufficientReservesError: true = true
public constructor() {
super()
this.name = this.constructor.name
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype)
}
}
/**
* Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less
* than the price of a single unit of output after fees.
*/
export class InsufficientInputAmountError extends Error {
public readonly isInsufficientInputAmountError: true = true
public constructor() {
super()
this.name = this.constructor.name
if (CAN_SET_PROTOTYPE) Object.setPrototypeOf(this, new.target.prototype)
}
}