diff --git a/src/FetchWorkerTool.worker.js b/src/FetchWorkerTool.worker.js index 43965250..be87df0d 100644 --- a/src/FetchWorkerTool.worker.js +++ b/src/FetchWorkerTool.worker.js @@ -49,7 +49,10 @@ const onMessage = ({data: job}) => { jobsActive++; fetch(job.url, job.options) - .then(response => response.arrayBuffer()) + .then(result => { + if (result.ok) return result.arrayBuffer(); + return Promise.reject(result.status); + }) .then(buffer => complete.push({id: job.id, buffer})) .catch(error => complete.push({id: job.id, error})) .then(() => jobsActive--);