Skip to content

Commit

Permalink
merge: (#283) LocalDateTime 예외 처리 (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut authored Jan 8, 2023
2 parents 3e04f04 + a5a7347 commit 3163002
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import team.comit.simtong.global.error.dto.ErrorResponse
*
* @author kimbeomjin
* @date 2022/08/22
* @version 1.0.0
* @version 1.2.3
**/
@RestControllerAdvice
class GlobalErrorHandler {
Expand All @@ -28,13 +28,4 @@ class GlobalErrorHandler {
): ErrorResponse? {
return ErrorResponse.of(exception)
}

/**
* 적합하지 않거나 적절하지 못한 인자를 메서드에 넘기면 발생
*/
@ExceptionHandler(IllegalArgumentException::class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
protected fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse? {
return ErrorResponse.of(exception)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import javax.validation.ConstraintViolationException
* @author kimbeomjin
* @author Chokyunghyeon
* @date 2022/08/22
* @version 1.0.0
* @version 1.2.3
**/
@RestControllerAdvice
class WebErrorHandler {
Expand Down Expand Up @@ -72,15 +72,6 @@ class WebErrorHandler {
return ErrorResponse.of(exception)
}

/**
* 적합하지 않거나 적절하지 못한 인자를 메서드에 넘기면 발생
*/
@ExceptionHandler(IllegalArgumentException::class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
protected fun handleIllegalArgumentException(exception: IllegalArgumentException): ErrorResponse? {
return ErrorResponse.of(GlobalExceptions.BadRequest())
}

/**
* 지원하지 않은 HTTP method 호출할 경우 발생
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class ErrorResponse(

fun of(exception: MethodArgumentTypeMismatchException): ErrorResponse {
val value = exception.value
val fieldErrors = CustomFieldError.of(exception.name, value.toString(), exception.errorCode)
val fieldErrors = CustomFieldError.of(
field = exception.parameter.parameterName ?: "",
value = value.toString(),
reason = "${exception.requiredType!!.name} 타입으로 변환할 수 없습니다."
)

return of(
exception = GlobalExceptions.BadRequest(),
Expand Down

0 comments on commit 3163002

Please sign in to comment.