- 
                Notifications
    You must be signed in to change notification settings 
- Fork 200
[5기 김남규, 박유진] Spring Boot JPA 게시판 구현 미션 제출합니다. #269
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
base: eugene_namgyu
Are you sure you want to change the base?
Changes from 1 commit
5d1b20c
              e67814f
              71f3790
              3bc557b
              b0c5ecb
              426d642
              7fbe52e
              91b8736
              ec97bec
              5f485c8
              462b862
              1c49847
              bc065c9
              f4d7a9b
              afa8a7d
              8bfc7d2
              ff17326
              95e91f8
              d15af2a
              33b67e2
              c008314
              268882d
              cc0e870
              63ed5a5
              35628e6
              b01f6ed
              57127d9
              4cafb55
              f6a301b
              0b112f1
              0f91afa
              6599c3c
              bdda4e9
              055fdd0
              71d2f67
              226bcac
              2068b99
              100260e
              e4bc9c1
              bd2b1ca
              858c1ac
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,23 +1,25 @@ | ||
| package com.prgrms.dev.springbootboardjpa.exception; | ||
|  | ||
| import com.prgrms.dev.springbootboardjpa.ApiResponse; | ||
| import com.prgrms.dev.springbootboardjpa.controller.PostController; | ||
| import org.springframework.data.crossstore.ChangeSetPersister; | ||
| import org.springframework.http.ResponseEntity; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.RestControllerAdvice; | ||
| import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; | ||
|  | ||
| @RestControllerAdvice | ||
| @RestControllerAdvice(basePackageClasses = PostController.class) | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 패키지는 공통 exception이지만 포스트 컨트롤러에 대해서만 적용하신 이유가 있나요? | ||
| public class GlobalExceptionHandler { | ||
|  | ||
| private static final int NOT_FOUND = 404; | ||
| private static final int INTERNAL_SERVER_ERROR = 500; | ||
|  | ||
| @ExceptionHandler(ChangeSetPersister.NotFoundException.class) | ||
| public ApiResponse<String> notFoundHandler(ChangeSetPersister.NotFoundException e) { | ||
| return ApiResponse.fail(NOT_FOUND, e.getMessage()); | ||
| public ResponseEntity<String> notFoundHandler(ChangeSetPersister.NotFoundException e) { | ||
| return ResponseEntity.status(NOT_FOUND).body(e.getMessage()); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HttpStatusCode를 활용하는걸 고려해보세요. | ||
| } | ||
|  | ||
| @ExceptionHandler(Exception.class) | ||
| public ApiResponse<String> internalServerErrorHandler(Exception e) { | ||
| return ApiResponse.fail(INTERNAL_SERVER_ERROR, e.getMessage()); | ||
| } // 다음 타자 ................. | ||
| public ResponseEntity<String> internalServerErrorHandler(Exception e) { | ||
| return ResponseEntity.status(INTERNAL_SERVER_ERROR).body(e.getMessage()); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HttpStatusCode를 활용하는걸 고려해보세요. | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pageable로 받는 부분을 수정해보면 좋을 것 같네요 👍