Fix error handling

This commit is contained in:
kwaroran
2024-01-06 22:43:59 +09:00
parent 8eccda086d
commit f638866308

View File

@@ -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]