Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
Fix confusing error when XHR statusText is blank
Browse files Browse the repository at this point in the history
In the existing `Error(xhr.statusText + ': ' + url || 'XHR error')` implementation, the LHS of the OR is always truthy, so XHR failures with no statusText yield error messages like `: google.com`. This edit changes that to a slightly-less-cryptic `XHR error: status 0 "": http://google.com` (which yields useful results in a web search), or if there is a statusText, `XHR error: status 403 "Forbidden": http://mydomain.com/page`.

(Feel free to just change it directly in the codebase instead of merging if you prefer different formatting, etc.)
  • Loading branch information
msegado committed Jul 31, 2015
1 parent 64a5d70 commit 8b4dd47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/system-fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
fulfill(xhr.responseText);
}
function error() {
reject(new Error(xhr.statusText + ': ' + url || 'XHR error'));
reject(new Error('XHR error: status ' + xhr.status + ' "' + xhr.statusText + '": ' + url));
}

xhr.onreadystatechange = function () {
Expand Down

0 comments on commit 8b4dd47

Please sign in to comment.