Skip to content

Commit 44042d0

Browse files
author
Bryan Bonnet
committed
fix(TimeoutError): Add name to TimeoutError
1 parent 576d943 commit 44042d0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

spec/operators/timeout-spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ describe('Observable.prototype.timeout', () => {
2525
it('should emit and error of an instanceof TimeoutError on timeout', () => {
2626
const e1 = cold('-------a--b--|');
2727
const result = e1.timeout(50, rxTestScheduler);
28+
let error;
2829
result.subscribe(() => {
2930
throw new Error('this should not next');
3031
}, err => {
31-
expect(err).to.be.an.instanceof(Rx.TimeoutError);
32+
error = err;
3233
}, () => {
3334
throw new Error('this should not complete');
3435
});
3536
rxTestScheduler.flush();
37+
expect(error).to.be.an.instanceof(Rx.TimeoutError);
38+
expect(error.name).to.equal('TimeoutError');
3639
});
3740

3841
it('should not timeout if source completes within absolute timeout period', () => {

src/internal/util/TimeoutError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
export class TimeoutError extends Error {
99
constructor() {
1010
super('Timeout has occurred');
11-
11+
this.name = 'TimeoutError';
1212
(Object as any).setPrototypeOf(this, TimeoutError.prototype);
1313
}
1414
}

0 commit comments

Comments
 (0)