Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
errors: Recognize HTTP status 0 as AbortError (#243)
Browse files Browse the repository at this point in the history
This only happens when the browser itself is aborting the request due to e.g. a page reload, which seems impossible to test within our test framework.
  • Loading branch information
Turbo87 authored and alexlafroscia committed Feb 20, 2017
1 parent f624aa4 commit 174b121
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ export function isTimeoutError(error) {
* @return {Boolean}
*/
export function isAbortError(error) {
return error instanceof AbortError;
if (isAjaxError(error)) {
return error instanceof AbortError;
} else {
return error === 0;
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/errors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ describe('unit/errors-test - AjaxError', function() {
});

describe('isAbortError', function() {
it('detects error code correctly', function() {
ok(isAbortError(0));
});

it('detects error class correctly', function() {
const error = new AbortError();
ok(isAbortError(error));
Expand Down

0 comments on commit 174b121

Please sign in to comment.