mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
UrlPlayer: process HTTP responses to invalid requests
This commit is contained in:
parent
4caf912ff1
commit
e7c1384436
1 changed files with 6 additions and 0 deletions
|
|
@ -26,10 +26,16 @@ const prepareVM = ({ url, setStatus, setParts }) => {
|
||||||
fetch(wasmBinaryName)
|
fetch(wasmBinaryName)
|
||||||
.then((response) => response.arrayBuffer())
|
.then((response) => response.arrayBuffer())
|
||||||
|
|
||||||
|
const checkResponse = (response) => {
|
||||||
|
if (response.ok) return response
|
||||||
|
throw new Error(response.statusText)
|
||||||
|
}
|
||||||
|
|
||||||
return Promise.resolve(url)
|
return Promise.resolve(url)
|
||||||
.then(st('loading', 'Downloading file'))
|
.then(st('loading', 'Downloading file'))
|
||||||
.then(cleanUrl)
|
.then(cleanUrl)
|
||||||
.then(fetch)
|
.then(fetch)
|
||||||
|
.then(checkResponse)
|
||||||
.then(st('loading', 'Processing file'))
|
.then(st('loading', 'Processing file'))
|
||||||
.then((response) => response.arrayBuffer())
|
.then((response) => response.arrayBuffer())
|
||||||
.then((arrayBuffer) => new Uint8Array(arrayBuffer))
|
.then((arrayBuffer) => new Uint8Array(arrayBuffer))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue