提交 67152c2a 编写于 作者: D David Graham

Reject promise with TypeError for network failures.

上级 502798d1
......@@ -162,7 +162,7 @@
xhr.onload = function() {
var status = (xhr.status === 1223) ? 204 : xhr.status
if (status < 100 || status > 599) {
reject()
reject(new TypeError('Network request failed'))
return
}
var options = {
......@@ -174,7 +174,7 @@
}
xhr.onerror = function() {
reject()
reject(new TypeError('Network request failed'))
}
xhr.open(self.method, self.url)
......
......@@ -54,8 +54,8 @@ asyncTest('rejects promise for network error', 1, function() {
fetch('/error').then(function(response) {
ok(false, 'HTTP status ' + response.status + ' was treated as success')
start()
}).catch(function() {
ok(true)
}).catch(function(error) {
ok(error instanceof TypeError, 'Rejected with Error')
start()
})
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册