Repository navigation
Expand file tree
/
Copy patherrors.js
More file actions
63 lines (52 loc) · 1.64 KB
/
Copy patherrors.js
File metadata and controls
63 lines (52 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
export class PlanValidationError extends Error {
constructor(message) {
super(message);
this.name = "PlanValidationError";
}
}
export class AiTemporaryUnavailableError extends Error {
constructor({ provider, status, attempts, cause }) {
super(
`${provider} este temporar indisponibil după ${attempts} încercări.`,
{ cause }
);
this.name = "AiTemporaryUnavailableError";
this.provider = provider;
this.status = status;
this.attempts = attempts;
}
}
export class ActionError extends Error {
constructor(message) {
super(message);
this.name = "ActionError";
}
}
export function formatDiscordError(error) {
const code = error?.code;
const status = error?.status;
if (error instanceof ActionError) {
return error.message;
}
if (code === 50013 || code === "Missing Permissions") {
return "Botul nu are permisiunile Discord necesare pentru această acțiune.";
}
if (code === 50001) {
return "Botul nu are acces la resursa Discord cerută.";
}
if (code === 10003 || code === 10008 || code === 10011) {
return "Ținta nu mai există sau a fost ștearsă între timp.";
}
if (status === 429 || code === 429) {
return "Discord a limitat temporar cererile. Încearcă din nou peste puțin timp.";
}
if (code === 50034) {
return "Discord nu permite ștergerea în masă a mesajelor mai vechi de 14 zile.";
}
if (error?.name === "AbortError") {
return "Operația Discord a expirat înainte să se termine.";
}
return error?.message
? `Discord a refuzat acțiunea: ${error.message}`
: "Acțiunea Discord a eșuat dintr-un motiv necunoscut.";
}