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