kopia lustrzana https://github.com/badgen/badgen.net
feat: improve error status
rodzic
1e7341b27e
commit
cdc67e609d
|
@ -26,11 +26,16 @@ async function fetchLiveParams (scope, fn, paramsPath) {
|
||||||
|
|
||||||
console.time(fetchKey)
|
console.time(fetchKey)
|
||||||
waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => {
|
waitings[fetchKey] = fn(...paramsPath.split('/')).catch(e => {
|
||||||
console.error(fetchKey, 'LIVE_ERROR', e.message)
|
let status = 'unknown'
|
||||||
return {
|
|
||||||
failed: true,
|
if (e.response && e.response.status === 404) {
|
||||||
status: e.code === 'ECONNABORTED' ? 'timeout' : 'unknown'
|
status = 'not found'
|
||||||
|
} else if (e.code === 'ECONNABORTED') {
|
||||||
|
status = 'timeout'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.error(fetchKey, `LIVEFN_ERR<${status}>`, e.message)
|
||||||
|
return { status, failed: true }
|
||||||
}).then(result => {
|
}).then(result => {
|
||||||
console.timeEnd(fetchKey)
|
console.timeEnd(fetchKey)
|
||||||
waitings[fetchKey] = undefined
|
waitings[fetchKey] = undefined
|
||||||
|
|
Ładowanie…
Reference in New Issue