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

Commit 8b4dd47

Browse files
committed
Fix confusing error when XHR statusText is blank
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.)
1 parent 64a5d70 commit 8b4dd47

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/system-fetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
fulfill(xhr.responseText);
3434
}
3535
function error() {
36-
reject(new Error(xhr.statusText + ': ' + url || 'XHR error'));
36+
reject(new Error('XHR error: status ' + xhr.status + ' "' + xhr.statusText + '": ' + url));
3737
}
3838

3939
xhr.onreadystatechange = function () {

0 commit comments

Comments
 (0)