diff --git a/src/main/java/life/mosu/mosuserver/global/exception/GlobalExceptionHandler.java b/src/main/java/life/mosu/mosuserver/global/exception/GlobalExceptionHandler.java index 88a98c2c..ba4125b5 100644 --- a/src/main/java/life/mosu/mosuserver/global/exception/GlobalExceptionHandler.java +++ b/src/main/java/life/mosu/mosuserver/global/exception/GlobalExceptionHandler.java @@ -23,18 +23,6 @@ public class GlobalExceptionHandler { private final NotifyClientAdapter notifier; - private void notifyIfNeeded(Exception ex) { - try { - DiscordExceptionNotifyEventRequest request = DiscordExceptionNotifyEventRequest.of( - ex.getCause().toString(), - ex.getMessage() - ); - notifier.send(request); - } catch (Exception notifyEx) { - log.error("[Discord Notify Error]", notifyEx); - } - } - @ExceptionHandler(MethodArgumentNotValidException.class) public ResponseEntity handleMethodArgumentNotValidException( MethodArgumentNotValidException ex) { @@ -94,9 +82,9 @@ public ResponseEntity handleAuthenticationException(Authenticatio return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); } - @ExceptionHandler(life.mosu.mosuserver.global.exception.AuthenticationException.class) + @ExceptionHandler(AuthenticationException.class) public ResponseEntity handleCustomAuthenticationException( - life.mosu.mosuserver.global.exception.AuthenticationException ex) { + AuthenticationException ex) { notifyIfNeeded(ex); ErrorResponse response = ErrorResponse.builder() @@ -160,4 +148,16 @@ public ResponseEntity handleCustomRuntimeException(CustomRuntimeE return ResponseEntity.status(ex.getStatus()).body(response); } + + private void notifyIfNeeded(Exception ex) { + try { + DiscordExceptionNotifyEventRequest request = DiscordExceptionNotifyEventRequest.of( + ex.getCause().toString(), + ex.getMessage() + ); + notifier.send(request); + } catch (Exception notifyEx) { + log.error("[Discord Notify Error]", notifyEx); + } + } } diff --git a/src/main/java/life/mosu/mosuserver/infra/notify/dto/discord/DiscordExceptionNotifyEventRequest.java b/src/main/java/life/mosu/mosuserver/infra/notify/dto/discord/DiscordExceptionNotifyEventRequest.java index f13b8b63..9677e804 100644 --- a/src/main/java/life/mosu/mosuserver/infra/notify/dto/discord/DiscordExceptionNotifyEventRequest.java +++ b/src/main/java/life/mosu/mosuserver/infra/notify/dto/discord/DiscordExceptionNotifyEventRequest.java @@ -22,7 +22,7 @@ public static DiscordExceptionNotifyEventRequest of( } public String getMessage() { - return "❌ **알림 전송 실패**\n" + return "⚠️ **알림 전송**\n" + String.format("- ⚠️ exception Cause : `%s`\n", exceptionCause) + String.format("- 📨 exception Message: `%s`\n", exceptionMessage) + String.format("- 📋 meta: `%s`", meta == null ? "없음" : meta);