api: move error context to matcher

This commit is contained in:
wukko
2024-08-24 16:56:07 +06:00
parent 37efa035a2
commit 7ac0726f37
13 changed files with 33 additions and 85 deletions

View File

@@ -246,9 +246,27 @@ export default async function(host, patternMatch, obj) {
}
if (r.error) {
let context;
switch(r.error) {
case "content.too_long":
context = {
limit: env.durationLimit / 60,
}
break;
case "fetch.fail":
case "fetch.rate":
case "content.video.unavailable":
case "link.unsupported":
context = {
service: host,
}
break;
}
return createResponse("error", {
code: `error.api.${r.error}`,
context: r?.context
context
})
}