Initial commit

This commit is contained in:
SoftUniq
2024-11-13 22:31:18 +00:00
commit abfa7b43af
21 changed files with 8368 additions and 0 deletions

24
src/utils/errorHandler.js Normal file
View File

@@ -0,0 +1,24 @@
export default class ErrorHandler {
static async handleError(bot, chatId, error, context) {
console.error(`Error in ${context}:`, error);
const errorMessage = process.env.NODE_ENV === 'development'
? `Error: ${error.message}`
: 'An error occurred. Please try again later.';
try {
await bot.sendMessage(chatId, errorMessage);
} catch (sendError) {
console.error('Error sending error message:', sendError);
}
}
static handlePollingError(error) {
if (error.code === 'ETELEGRAM') {
console.error('Telegram API Error:', error.message);
process.exit(1);
} else {
console.error('Polling error:', error);
}
}
}