From c96f4ea9e61d2396bcae7c606d890abcaa00fb86 Mon Sep 17 00:00:00 2001 From: Bob Sin Date: Fri, 12 Apr 2024 02:00:30 +0900 Subject: [PATCH] =?UTF-8?q?[KAN-21]=20global=20exception=20error=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=95=88=EB=90=98=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/exception/GlobalExceptionHandler.kt | 16 ++++++---------- .../be/user/domain/service/SignUpUserService.kt | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/restaurant/be/common/exception/GlobalExceptionHandler.kt b/src/main/kotlin/com/restaurant/be/common/exception/GlobalExceptionHandler.kt index 27ffb87..6b2e2dc 100644 --- a/src/main/kotlin/com/restaurant/be/common/exception/GlobalExceptionHandler.kt +++ b/src/main/kotlin/com/restaurant/be/common/exception/GlobalExceptionHandler.kt @@ -12,17 +12,16 @@ import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.ResponseStatus import org.springframework.web.bind.annotation.RestControllerAdvice import org.springframework.web.bind.support.WebExchangeBindException -import org.springframework.web.server.ServerWebExchange import org.springframework.web.server.ServerWebInputException import java.security.SignatureException @RestControllerAdvice class GlobalExceptionHandler { - @ExceptionHandler(ServerException::class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(value = [ServerException::class]) fun handleServerException( - ex: ServerException, - exchange: ServerWebExchange + ex: ServerException ): ResponseEntity { val response = CommonResponse.fail(ex.message, ex.javaClass.simpleName) return ResponseEntity(response, null, ex.code) @@ -31,8 +30,7 @@ class GlobalExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(value = [ServerWebInputException::class]) fun methodArgumentNotValidException( - e: ServerWebInputException, - exchange: ServerWebExchange + e: ServerWebInputException ): CommonResponse { val data = if (e.cause?.cause is MissingKotlinParameterException) { @@ -51,8 +49,7 @@ class GlobalExceptionHandler { @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(value = [WebExchangeBindException::class]) fun methodArgumentNotValidException( - e: WebExchangeBindException, - exchange: ServerWebExchange + e: WebExchangeBindException ): CommonResponse { val errors = mutableListOf() e.allErrors.forEach { @@ -84,8 +81,7 @@ class GlobalExceptionHandler { @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(value = [Exception::class]) fun exception( - e: Exception, - exchange: ServerWebExchange + e: Exception ): CommonResponse { val errorResponse = CommonResponse.fail(e.message, e::class.java.simpleName) return errorResponse diff --git a/src/main/kotlin/com/restaurant/be/user/domain/service/SignUpUserService.kt b/src/main/kotlin/com/restaurant/be/user/domain/service/SignUpUserService.kt index 94b4d45..74008aa 100644 --- a/src/main/kotlin/com/restaurant/be/user/domain/service/SignUpUserService.kt +++ b/src/main/kotlin/com/restaurant/be/user/domain/service/SignUpUserService.kt @@ -8,8 +8,8 @@ import com.restaurant.be.user.presentation.dto.SignUpUserRequest import com.restaurant.be.user.presentation.dto.SignUpUserResponse import com.restaurant.be.user.repository.UserRepository import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional import java.util.concurrent.TimeUnit -import javax.transaction.Transactional @Service class SignUpUserService(