also use cached response for server errors

This commit is contained in:
2025-01-26 16:50:37 +00:00
parent 32e8cc8054
commit e7ba689f14
+6 -4
View File
@@ -67,12 +67,14 @@ export default class WebStorage {
} }
} }
} }
return this.#fetch(resource, options).then( return this.#fetch(resource, options)
response => { .then(async response => {
if (response.status >= 500) {
throw new Error(response.statusText + '\n' + await response.text())
}
this.#cache.put(resource, response) this.#cache.put(resource, response)
return response return response
}, }).catch(error => {
error => {
console.warn(error) console.warn(error)
return this.#cache.match(resource) return this.#cache.match(resource)
} }