api: update error codes in api core functions
This commit is contained in:
@@ -39,7 +39,7 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
|
||||
switch (action) {
|
||||
default:
|
||||
return createResponse("error", {
|
||||
code: "ErrorEmptyDownload"
|
||||
code: "error.api.fetch.empty"
|
||||
});
|
||||
|
||||
case "photo":
|
||||
@@ -149,7 +149,7 @@ export default function({ r, host, audioFormat, isAudioOnly, isAudioMuted, disab
|
||||
case "audio":
|
||||
if (audioIgnore.includes(host) || (host === "reddit" && r.typeId === "redirect")) {
|
||||
return createResponse("error", {
|
||||
code: "ErrorEmptyDownload"
|
||||
code: "error.api.fetch.empty"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ export default async function(host, patternMatch, obj) {
|
||||
|
||||
if (!testers[host]) {
|
||||
return createResponse("error", {
|
||||
code: "ErrorUnsupported"
|
||||
code: "error.api.service.unsupported"
|
||||
});
|
||||
}
|
||||
if (!(testers[host](patternMatch))) {
|
||||
return createResponse("error", {
|
||||
code: "ErrorBrokenLink",
|
||||
code: "error.api.link.invalid",
|
||||
context: {
|
||||
service: host
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export default async function(host, patternMatch, obj) {
|
||||
|
||||
default:
|
||||
return createResponse("error", {
|
||||
code: "ErrorUnsupported"
|
||||
code: "error.api.service.unsupported"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ export default async function(host, patternMatch, obj) {
|
||||
})
|
||||
} catch {
|
||||
return createResponse("error", {
|
||||
code: "ErrorBadFetch",
|
||||
code: "error.api.fetch.critical",
|
||||
context: {
|
||||
service: host
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ export function createResponse(responseType, responseData) {
|
||||
body: {
|
||||
status: "error",
|
||||
error: {
|
||||
code: code || "Internal Server Error",
|
||||
code: code || "error.api.fetch.critical",
|
||||
},
|
||||
critical: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user