🔧 fix(telegram-bot): improve database connection logging and error messages

- Add connection test on startup (SELECT 1)
- Log masked database URL on connection attempt
- Better error messages for /users command
This commit is contained in:
Till-JS 2026-01-26 11:14:52 +01:00
parent 79e3c09af2
commit 021c6e789e
2 changed files with 23 additions and 9 deletions

View file

@ -67,13 +67,21 @@ export class BotUpdate {
this.logger.log(`/users command from ${ctx.from?.id}`);
await ctx.reply('👥 Lade User-Statistiken...');
const stats = await this.usersService.getUserStats();
if (!stats) {
await ctx.reply('❌ Datenbank nicht verfügbar');
return;
}
try {
const stats = await this.usersService.getUserStats();
if (!stats) {
this.logger.warn('User stats returned null - database may not be configured');
await ctx.reply('❌ Datenbank nicht verfügbar. Prüfe DATABASE_URL Konfiguration.');
return;
}
const report = formatUsersReport(stats);
await ctx.replyWithHTML(report);
const report = formatUsersReport(stats);
await ctx.replyWithHTML(report);
} catch (error) {
this.logger.error('Failed to get user stats:', error);
await ctx.reply(
`❌ Fehler beim Laden der User-Statistiken: ${error instanceof Error ? error.message : 'Unbekannter Fehler'}`
);
}
}
}