Skip to content

Commit 576d943

Browse files
author
Bryan Bonnet
committed
fix(ajax): RxJS v6 TimeoutError is missing name property
1 parent 7e4cef4 commit 576d943

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

spec/observables/dom/ajax-spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ describe('Observable.ajax', () => {
273273
});
274274

275275
expect(error instanceof Rx.AjaxError).to.be.true;
276+
expect(error.name).to.equal('AjaxError');
276277
expect(error.message).to.equal('ajax error 404');
277278
expect(error.status).to.equal(404);
278279
});
@@ -843,7 +844,7 @@ describe('Observable.ajax', () => {
843844
delete root.XMLHttpRequest.prototype.onreadystatechange;
844845
});
845846

846-
it('should work fine when XMLHttpRequest ontimeout property is monkey patched', function() {
847+
it('should work fine when XMLHttpRequest ontimeout property is monkey patched', function(done) {
847848
Object.defineProperty(root.XMLHttpRequest.prototype, 'ontimeout', {
848849
set(fn: (e: ProgressEvent) => any) {
849850
const wrapFn = (ev: ProgressEvent) => {
@@ -867,7 +868,8 @@ describe('Observable.ajax', () => {
867868
Rx.Observable.ajax(ajaxRequest)
868869
.subscribe({
869870
error(err) {
870-
/* expected, ignore */
871+
expect(err.name).to.equal('AjaxTimeoutError');
872+
done();
871873
}
872874
});
873875

src/internal/observable/dom/AjaxObservable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ function parseXhrResponse(responseType: string, xhr: XMLHttpRequest) {
490490
export class AjaxTimeoutError extends AjaxError {
491491
constructor(xhr: XMLHttpRequest, request: AjaxRequest) {
492492
super('ajax timeout', xhr, request);
493+
this.name = 'AjaxTimeoutError';
493494
(Object as any).setPrototypeOf(this, AjaxTimeoutError.prototype);
494495
}
495496
}

0 commit comments

Comments
 (0)