-
Notifications
You must be signed in to change notification settings - Fork 13
[Spring Core] 김민준B 과제 제출합니다. #4
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: main
Are you sure you want to change the base?
Conversation
ImTotem
left a comment
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.
고생하셨습니다
점점 깔끔해지는게 보이네요
| public ResponseEntity<ErrorResponse> RequestNullExistException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.REQUEST_NULL_VALUE); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(400)); | ||
| } | ||
|
|
||
| @ExceptionHandler(MemberNotExistException.class) | ||
| public ResponseEntity<ErrorResponse> MemberNotExistException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.MEMBER_NOT_EXIST); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(400)); | ||
| } | ||
|
|
||
| @ExceptionHandler(BoardNotExistException.class) | ||
| public ResponseEntity<ErrorResponse> BoardNotExistException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.BOARD_NOT_EXIST); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(400)); | ||
| } | ||
|
|
||
| @ExceptionHandler(ArticleNotFoundException.class) | ||
| public ResponseEntity<ErrorResponse> ArticleNotFoundException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.ARTICLE_NOT_EXIST); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(404)); | ||
| } | ||
|
|
||
| @ExceptionHandler(MemberNotFoundException.class) | ||
| public ResponseEntity<ErrorResponse> MemberNotFoundException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.MEMBER_NOT_FOUND); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(404)); | ||
| } | ||
|
|
||
| @ExceptionHandler(BoardNotFoundException.class) | ||
| public ResponseEntity<ErrorResponse> BoardNotFoundException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.BOARD_NOT_FOUND); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(404)); | ||
| } | ||
|
|
||
| @ExceptionHandler(AlreadyHasEmailException.class) | ||
| public ResponseEntity<ErrorResponse> AlreadyHasEmailException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.EMAIL_EXIST); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(409)); | ||
| } | ||
|
|
||
| @ExceptionHandler(MemberHasArticleException.class) | ||
| public ResponseEntity<ErrorResponse> MemberHasArticleException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.MEMBER_ARTICLE_EXIST); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(400)); | ||
| } | ||
|
|
||
| @ExceptionHandler(BoardHasArticleException.class) | ||
| public ResponseEntity<ErrorResponse> BoardHasArticleException() { |
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.
자바 naming convention은 지켜주세요
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.
참고하고 다음 실습 때 고치도록 하겠습니다!
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.
gitignore로 제외해주세요
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.
넵 제외하겠습니다! 궁금해서 묻는건데 제외하는 이유가 있나요??
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.
application.yml에는 유출되면 보안에 치명적인 정보가 많이 들어있어요.
그래서 원격에 올릴 경우 막대한 피해를 보게 될 수도 있어서 application.yml등과 같은 민감한 파일은 올리지 않는 것이 좋아요.
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.
아하 그렇군요! 알겠습니다!
| private final int status; | ||
| private final String code; |
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.
Status Code는 상태 코드라고 불리며 숫자로 나타냅니다.
결국 Status Code는 상태를 나타내는 코드(숫자)를 의미한다고 생각해요.
따라서 code가 int, status가 String이어야 된다고 생각해요.
status가 int, code가 String인 이유가 있나요?
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.
앗... 지금 보니까 설정이 뒤바뀌었네요.. 고치도록 할게요!
| @ExceptionHandler(RequestNullExistException.class) | ||
| public ResponseEntity<ErrorResponse> RequestNullExistException() { | ||
| ErrorResponse response = new ErrorResponse(ErrorCode.REQUEST_NULL_VALUE); | ||
| return new ResponseEntity<>(response, HttpStatusCode.valueOf(400)); |
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.
ErrorCode.REQUEST_NULL_VALUE.getStatus()를 안쓰고 HttpStatus.valueOf(400)로 직접 지정한 이유가 있나요?
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.
getStatus를 써도 같은 결과가 발생하는 군요! 하나 더 배워갑니다!
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.
깔끔 하네요 👍
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.
👍
| public class GlobalExceptionHandler { | ||
|
|
||
| @ExceptionHandler(RequestNullExistException.class) | ||
| public ResponseEntity<ErrorResponse> RequestNullExistException() { |
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.
Exception에 message가 담겨있는 message를 반환해야할 경우에는 어떻게 핸들링 해야할지 생각해보세요 :)
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.
사용자 지정 Exception 매개변수에 message를 넣어서 반환하면 됩니다!
감사합니다.👍 |
구글 문서에 작성해두겠습니다.