From 20449a0cb293649d9c301781dd89e7c26cc7a6b6 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 20 Nov 2017 11:13:54 -0600 Subject: Throw when subscription is already removed --- packages/0x.js/src/order_watcher/expiration_watcher.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'packages') diff --git a/packages/0x.js/src/order_watcher/expiration_watcher.ts b/packages/0x.js/src/order_watcher/expiration_watcher.ts index 6d9556336..f9c6571db 100644 --- a/packages/0x.js/src/order_watcher/expiration_watcher.ts +++ b/packages/0x.js/src/order_watcher/expiration_watcher.ts @@ -35,7 +35,10 @@ export class ExpirationWatcher { ); } public unsubscribe(): void { - intervalUtils.clearAsyncExcludingInterval(this.orderExpirationCheckingIntervalIdIfExists as NodeJS.Timer); + if (_.isUndefined(this.orderExpirationCheckingIntervalIdIfExists)) { + throw new Error(ZeroExError.SubscriptionNotFound); + } + intervalUtils.clearAsyncExcludingInterval(this.orderExpirationCheckingIntervalIdIfExists); delete this.callbackIfExists; } public addOrder(orderHash: string, expirationUnixTimestampSec: BigNumber): void { -- cgit v1.2.3