diff --git a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/common/ExceptionHandler.kt b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/common/ExceptionHandler.kt index 6cc7c32..9f9a794 100644 --- a/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/common/ExceptionHandler.kt +++ b/놀이터(예제 코드 작성)/playground/src/main/kotlin/com/banjjoknim/playground/common/ExceptionHandler.kt @@ -27,9 +27,15 @@ class ExceptionHandler : ResponseEntityExceptionHandler() { return ResponseEntity.badRequest().body(errors) } - @ExceptionHandler(value = [Exception::class]) - fun handleException(ex: Exception): ResponseEntity { + @ExceptionHandler(value = [NoSuchElementException::class]) + fun handleNoSuchElement(ex: NoSuchElementException): ResponseEntity { logger.error("message", ex) - return ResponseEntity.internalServerError().build() + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(ex.message) + } + + @ExceptionHandler(value = [Exception::class]) + fun handleException(ex: Exception): ResponseEntity { + logger.error("message", ex) + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(ex.message) } }