Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KAN-21] global exception error 처리 안되는 버그 수정 #14

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ 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)
@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 +29,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 +48,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 +80,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
Loading