mirror of
https://github.com/complexcaresolutions/telegram-media-bot.git
synced 2026-03-17 16:13:42 +00:00
fix: user-friendly error messages for rate limit and auth errors
Show German messages with retry time for 429 and helpful guidance for 401 instead of raw API error JSON. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f148856b1d
commit
0d9d7a2971
1 changed files with 15 additions and 6 deletions
|
|
@ -129,12 +129,21 @@ async function processUpload(
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errMsg = error instanceof Error ? error.message : 'Unbekannter Fehler';
|
const errMsg = error instanceof Error ? error.message : 'Unbekannter Fehler';
|
||||||
log.error(`Upload failed for ${filename}`, error);
|
log.error(`Upload failed for ${filename}`, error);
|
||||||
await ctx.api.editMessageText(
|
|
||||||
ctx.chat!.id,
|
let userMsg: string;
|
||||||
statusMessageId,
|
if (errMsg.includes('429') || errMsg.includes('RATE_LIMITED')) {
|
||||||
`\u274c Upload fehlgeschlagen: ${escapeMarkdown(errMsg)}`,
|
const match = errMsg.match(/"retryAfter":(\d+)/);
|
||||||
{ parse_mode: 'MarkdownV2' },
|
const secs = match ? match[1] : '60';
|
||||||
);
|
userMsg = `\u23f3 Server\\-Rate\\-Limit erreicht\\. Bitte warte ${secs} Sekunden und versuche es dann erneut\\.`;
|
||||||
|
} else if (errMsg.includes('401') || errMsg.includes('incorrect')) {
|
||||||
|
userMsg = `\u274c Anmeldung am CMS fehlgeschlagen\\. Bitte den Admin kontaktieren\\.`;
|
||||||
|
} else {
|
||||||
|
userMsg = `\u274c Upload fehlgeschlagen: ${escapeMarkdown(errMsg)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.api.editMessageText(ctx.chat!.id, statusMessageId, userMsg, {
|
||||||
|
parse_mode: 'MarkdownV2',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue