Skip to content

Commit

Permalink
fix: log AOP 제거 및 SlackExceptionHandler 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kmebin committed Dec 3, 2023
1 parent fed1850 commit d4b5682
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 46 deletions.
28 changes: 0 additions & 28 deletions src/main/java/com/moabam/global/common/util/LogAspect.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,47 @@ public class GlobalExceptionHandler {

@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NotFoundException.class)
protected ErrorResponse handleNotFoundException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleNotFoundException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class)
protected ErrorResponse handleUnauthorizedException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleUnauthorizedException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(ForbiddenException.class)
protected ErrorResponse handleForbiddenException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleForbiddenException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.CONFLICT)
@ExceptionHandler(ConflictException.class)
protected ErrorResponse handleConflictException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleConflictException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(BadRequestException.class)
protected ErrorResponse handleBadRequestException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleBadRequestException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler({
FcmException.class,
TossPaymentException.class
})
protected ErrorResponse handleFcmException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleFcmException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MoabamException.class)
protected ErrorResponse handleMoabamException(MoabamException moabamException) {
return new ErrorResponse(moabamException.getMessage(), null);
protected ErrorResponse handleMoabamException(MoabamException exception) {
return new ErrorResponse(exception.getMessage(), null);
}

@ResponseStatus(HttpStatus.BAD_REQUEST)
Expand All @@ -95,7 +95,7 @@ protected ErrorResponse handleMethodArgumentNotValidException(MethodArgumentNotV

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ErrorResponse handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException exception) {
protected ErrorResponse handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException exception) {
String typeName = Optional.ofNullable(exception.getRequiredType())
.map(Class::getSimpleName)
.orElse("");
Expand All @@ -106,7 +106,7 @@ public ErrorResponse handleMethodArgumentTypeMismatchException(MethodArgumentTyp

@ExceptionHandler(MaxUploadSizeExceededException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorResponse handleMaxSizeException(MaxUploadSizeExceededException exception) {
protected ErrorResponse handleMaxSizeException(MaxUploadSizeExceededException exception) {
String message = String.format(S3_INVALID_IMAGE_SIZE.getMessage());

return new ErrorResponse(message, null);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.moabam.global.error.handler;

import org.springframework.context.annotation.Profile;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.moabam.api.infrastructure.slack.SlackService;
import com.moabam.global.error.model.ErrorResponse;

import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
Expand All @@ -16,9 +19,11 @@ public class SlackExceptionHandler {

private final SlackService slackService;

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
void handleException(HttpServletRequest request, Exception exception) throws Exception {
protected ErrorResponse handleException(HttpServletRequest request, Exception exception) throws Exception {
slackService.send(request, exception);
throw exception;

return new ErrorResponse(exception.getMessage(), null);
}
}

0 comments on commit d4b5682

Please sign in to comment.