Skip to content

Commit

Permalink
feat: NoResourceFoundException 처리 로직 추가 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Jan 23, 2024
1 parent 68424d5 commit 94b286f
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.resource.NoResourceFoundException;

@Slf4j
@RestControllerAdvice
Expand Down Expand Up @@ -68,6 +69,18 @@ protected ApiResponse<Object> handleInvalidFormatException(final Exception excep
return ApiResponse.error(ErrorCode.BAD_REQUEST_EXCEPTION);
}

/**
* 404 Not Found
*/
// 존재하지 않는 API 주소로 요청 시 발생
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(NoResourceFoundException.class)
protected ApiResponse<Object> handleNoResourceFoundException(
NoResourceFoundException exception) {
log.error(exception.getMessage(), exception);
return ApiResponse.error(ErrorCode.NO_RESOURCE_FOUND_EXCEPTION);
}


/**
* 405 Method Not Supported
Expand Down

0 comments on commit 94b286f

Please sign in to comment.