Skip to content

Commit

Permalink
refactor : 예외처리 응답 형식 변경, Internal Server Error 예외 처리 추가(#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
isprogrammingfun committed May 12, 2024
1 parent b568e71 commit d9a6759
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package com.bamyanggang.commonmodule.exception

import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.RestControllerAdvice

@RestControllerAdvice
class ExceptionHandler {
@ExceptionHandler(CustomException::class)
fun handleJwtException(e: CustomException): ErrorResponse{
return ErrorResponse(e.code, e.message, e.httpStatusCode)
fun handleJwtException(e: CustomException): ResponseEntity<ErrorResponse> {
return ResponseEntity(ErrorResponse(e.code, e.message), e.httpStatusCode)
}

}
@ExceptionHandler(Exception::class)
fun handleException(exception: Exception): ResponseEntity<ErrorResponse> {
return ResponseEntity(
ErrorResponse("INTERNAL_SERVER_ERROR", "Internal Server Error"),
HttpStatus.INTERNAL_SERVER_ERROR
)
}
}

0 comments on commit d9a6759

Please sign in to comment.