Skip to content

Commit

Permalink
fix(TimeoutError): Add name to TimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Bonnet committed May 7, 2018
1 parent 576d943 commit 44042d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion spec/operators/timeout-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/util/TimeoutError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export class TimeoutError extends Error {
constructor() {
super('Timeout has occurred');

this.name = 'TimeoutError';
(Object as any).setPrototypeOf(this, TimeoutError.prototype);
}
}

0 comments on commit 44042d0

Please sign in to comment.