Добавил ErrorHandlerService
This commit is contained in:
parent
d1c1783c63
commit
022fb152f7
@ -10,6 +10,7 @@ import dev.struchkov.bot.gitlab.telegram.unit.command.EnableProjectNotify;
|
||||
import dev.struchkov.bot.gitlab.telegram.unit.flow.InitSettingFlow;
|
||||
import dev.struchkov.godfather.main.core.unit.TypeUnit;
|
||||
import dev.struchkov.godfather.main.domain.content.Mail;
|
||||
import dev.struchkov.godfather.simple.context.service.ErrorHandler;
|
||||
import dev.struchkov.godfather.simple.context.service.EventHandler;
|
||||
import dev.struchkov.godfather.simple.context.service.PersonSettingService;
|
||||
import dev.struchkov.godfather.simple.context.service.UnitPointerService;
|
||||
@ -99,6 +100,7 @@ public class TelegramBotConfig {
|
||||
@Qualifier("messageExecutorService") ExecutorService executorService,
|
||||
TelegramSending sending,
|
||||
PersonSettingService personSettingService,
|
||||
ErrorHandler errorHandler,
|
||||
|
||||
StorylineService<Mail> storylineService
|
||||
) {
|
||||
@ -107,6 +109,7 @@ public class TelegramBotConfig {
|
||||
);
|
||||
autoresponder.initActionUnit(TypeUnit.BACK_CMD, new RollBackCmdAction<>(storylineService));
|
||||
autoresponder.setExecutorService(executorService);
|
||||
autoresponder.setErrorHandler(errorHandler);
|
||||
return autoresponder;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package dev.struchkov.bot.gitlab.telegram.service;
|
||||
|
||||
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||
import dev.struchkov.godfather.main.domain.content.Message;
|
||||
import dev.struchkov.godfather.simple.context.service.ErrorHandler;
|
||||
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ErrorHandlerService implements ErrorHandler {
|
||||
|
||||
private final TelegramSending telegramSending;
|
||||
|
||||
@Override
|
||||
public void handle(Message message, Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
final BoxAnswer boxAnswer = boxAnswer(e.getMessage());
|
||||
boxAnswer.setRecipientIfNull(message.getPersonId());
|
||||
telegramSending.send(boxAnswer);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user