Fix: download should throw status code
This commit is contained in:
parent
5f5b06b10c
commit
0c292c3150
|
@ -389,7 +389,7 @@ function download(url) {
|
||||||
.then(r => {
|
.then(r => {
|
||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
if (r.status !== 200) {
|
if (r.status !== 200) {
|
||||||
throw new Error(`Server responded failure code: ${r.status}`);
|
throw r.status;
|
||||||
}
|
}
|
||||||
return r.text();
|
return r.text();
|
||||||
})
|
})
|
||||||
|
@ -404,7 +404,7 @@ function download(url) {
|
||||||
xhr.timeout = TIMEOUT;
|
xhr.timeout = TIMEOUT;
|
||||||
xhr.onload = () => (xhr.status === 200 || url.protocol === 'file:'
|
xhr.onload = () => (xhr.status === 200 || url.protocol === 'file:'
|
||||||
? resolve(xhr.responseText)
|
? resolve(xhr.responseText)
|
||||||
: reject(new Error(`Server responded failure code: ${xhr.status}`)));
|
: reject(xhr.status));
|
||||||
xhr.onerror = reject;
|
xhr.onerror = reject;
|
||||||
xhr.open(options.method, url.href, true);
|
xhr.open(options.method, url.href, true);
|
||||||
for (const key of Object.keys(options.headers)) {
|
for (const key of Object.keys(options.headers)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user