From 44042d05c58721daa5278eb4816e0e9907d01731 Mon Sep 17 00:00:00 2001 From: Bryan Bonnet Date: Sun, 6 May 2018 20:02:56 -0700 Subject: [PATCH] fix(TimeoutError): Add name to TimeoutError --- spec/operators/timeout-spec.ts | 5 ++++- src/internal/util/TimeoutError.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/operators/timeout-spec.ts b/spec/operators/timeout-spec.ts index 184b63309e..ae5ca66941 100644 --- a/spec/operators/timeout-spec.ts +++ b/spec/operators/timeout-spec.ts @@ -25,14 +25,17 @@ describe('Observable.prototype.timeout', () => { it('should emit and error of an instanceof TimeoutError on timeout', () => { const e1 = cold('-------a--b--|'); const result = e1.timeout(50, rxTestScheduler); + let error; result.subscribe(() => { throw new Error('this should not next'); }, err => { - expect(err).to.be.an.instanceof(Rx.TimeoutError); + error = err; }, () => { throw new Error('this should not complete'); }); rxTestScheduler.flush(); + expect(error).to.be.an.instanceof(Rx.TimeoutError); + expect(error.name).to.equal('TimeoutError'); }); it('should not timeout if source completes within absolute timeout period', () => { diff --git a/src/internal/util/TimeoutError.ts b/src/internal/util/TimeoutError.ts index 506249e94d..11fda67697 100644 --- a/src/internal/util/TimeoutError.ts +++ b/src/internal/util/TimeoutError.ts @@ -8,7 +8,7 @@ export class TimeoutError extends Error { constructor() { super('Timeout has occurred'); - + this.name = 'TimeoutError'; (Object as any).setPrototypeOf(this, TimeoutError.prototype); } }