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)) {
|
||||
throw Error('unexpected response for sync, property version not found.')
|
||||
throw Error('unexpected response from /api/sync')
|
||||
}
|
||||
|
||||
// TODO: parse answer
|
||||
this.version = parseInt(response.version)
|
||||
} catch (e) {
|
||||
if (!e.response) {
|
||||
// request aborted or other causes
|
||||
return
|
||||
}
|
||||
|
||||
const { status, statusText } = e.response
|
||||
if (status == 200) {
|
||||
delay = 1000
|
||||
if (e.response) {
|
||||
// callApi() threw an exception
|
||||
const { status, statusText } = e.response
|
||||
if (status == 200) {
|
||||
delay = 1000
|
||||
} else {
|
||||
console.warn(`HTTP ${status} ${statusText}`)
|
||||
delay = 5000
|
||||
this.version = -1
|
||||
}
|
||||
} else {
|
||||
console.warn(`HTTP ${status} ${statusText}`)
|
||||
delay = 5000
|
||||
this.version = -1
|
||||
// request aborted or other causes
|
||||
console.warn(e.message)
|
||||
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