Fix error handling
This commit is contained in:
@@ -21,9 +21,9 @@ async function initTransformers(){
|
|||||||
await tfCache.put(url, response)
|
await tfCache.put(url, response)
|
||||||
},
|
},
|
||||||
match: async (url:URL|string) => {
|
match: async (url:URL|string) => {
|
||||||
console.log('match', url)
|
|
||||||
if(typeof url === 'string'){
|
if(typeof url === 'string'){
|
||||||
if(url.startsWith('/tf/Xenova/')){
|
if(url.startsWith('/tf/Xenova/')){
|
||||||
|
try {
|
||||||
const newURL = 'https://sv.risuai.xyz/transformers/' + url.substring(11)
|
const newURL = 'https://sv.risuai.xyz/transformers/' + url.substring(11)
|
||||||
const v = await tfCache.match(newURL)
|
const v = await tfCache.match(newURL)
|
||||||
if(v){
|
if(v){
|
||||||
@@ -32,6 +32,9 @@ async function initTransformers(){
|
|||||||
const response = await fetch(newURL)
|
const response = await fetch(newURL)
|
||||||
await tfCache.put(newURL, response.clone())
|
await tfCache.put(newURL, response.clone())
|
||||||
return response
|
return response
|
||||||
|
} catch (error) {
|
||||||
|
return await tfCache.match(url)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(Object.keys(tfMap).includes(url)){
|
if(Object.keys(tfMap).includes(url)){
|
||||||
const assetId = tfMap[url]
|
const assetId = tfMap[url]
|
||||||
|
|||||||
Reference in New Issue
Block a user