refactor: improve engine error handling
This commit is contained in:
parent
af19fd33fc
commit
2465e87a86
@ -18,24 +18,26 @@ export async function fetchUpdate() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!Number.isInteger(response.version)) {
|
if (!Number.isInteger(response.version)) {
|
||||||
throw Error('unexpected response for sync, property version not found.')
|
throw Error('unexpected response from /api/sync')
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: parse answer
|
// TODO: parse answer
|
||||||
this.version = parseInt(response.version)
|
this.version = parseInt(response.version)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!e.response) {
|
if (e.response) {
|
||||||
// request aborted or other causes
|
// callApi() threw an exception
|
||||||
return
|
const { status, statusText } = e.response
|
||||||
}
|
if (status == 200) {
|
||||||
|
delay = 1000
|
||||||
const { status, statusText } = e.response
|
} else {
|
||||||
if (status == 200) {
|
console.warn(`HTTP ${status} ${statusText}`)
|
||||||
delay = 1000
|
delay = 5000
|
||||||
|
this.version = -1
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn(`HTTP ${status} ${statusText}`)
|
// request aborted or other causes
|
||||||
delay = 5000
|
console.warn(e.message)
|
||||||
this.version = -1
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
{"authcode":"123456","name":"Harry","role":"player","game":"663576f0-1378-496b-a970-578bdcb222af","created":1650831122,"lastLoggedIn":1659475977}
|
{"authcode":"123456","name":"Harry","role":"player","game":"663576f0-1378-496b-a970-578bdcb222af","created":1650831122,"lastLoggedIn":1659540828}
|
Loading…
Reference in New Issue
Block a user