Skip to content

Commit

Permalink
[KAN-21] global exception error 처리 안되는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok committed Apr 11, 2024
1 parent d55b378 commit c96f4ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Any> {
val response = CommonResponse.fail(ex.message, ex.javaClass.simpleName)
return ResponseEntity(response, null, ex.code)
Expand All @@ -31,8 +30,7 @@ class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = [ServerWebInputException::class])
fun methodArgumentNotValidException(
e: ServerWebInputException,
exchange: ServerWebExchange
e: ServerWebInputException
): CommonResponse<String?> {
val data =
if (e.cause?.cause is MissingKotlinParameterException) {
Expand All @@ -51,8 +49,7 @@ class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = [WebExchangeBindException::class])
fun methodArgumentNotValidException(
e: WebExchangeBindException,
exchange: ServerWebExchange
e: WebExchangeBindException
): CommonResponse<String> {
val errors = mutableListOf<Error>()
e.allErrors.forEach {
Expand Down Expand Up @@ -84,8 +81,7 @@ class GlobalExceptionHandler {
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(value = [Exception::class])
fun exception(
e: Exception,
exchange: ServerWebExchange
e: Exception
): CommonResponse<String?> {
val errorResponse = CommonResponse.fail(e.message, e::class.java.simpleName)
return errorResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c96f4ea

Please sign in to comment.