-
Notifications
You must be signed in to change notification settings - Fork 0
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
[2주차] 기본 과제 #3
base: main
Are you sure you want to change the base?
[2주차] 기본 과제 #3
Conversation
과제 하느라 고생 많으셨습니다~! 🙌 |
Post post = postList.get((int) (postId - 1)); | ||
return new ResponseDto(post); | ||
} catch (Exception e) { | ||
throw new IllegalArgumentException("해당 아이디의 게시글이 존재하지 않습니다."); |
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.
return new ResponseDto(post); | ||
} | ||
} | ||
throw new IllegalArgumentException("해당 제목의 게시글이 존재하지 않습니다."); |
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 중, IllegalArgumentException를 선택하신 이유가 궁금합니다
Java에서 코딩할 때, Exception 클래스를 선택하는 기준이 있는지 궁금합니다!
바로 전자의 리뷰에서 ArrayList<T>.get()
메소드는 비정상적인 index 입력시,
IndexOutOfBoundsException를 throw 하는데, 동일한 exception을 발생시키는 건 어떻게 생각하시나요?
(제가 잘 몰라서 질문 던집니다.. ㅎ)
try {
...
} catch (Exception e) {
throw e;
}
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.
단순히 이제까지 Dto 단에서 @Valid 어노테이션을 이용해서 오류를 핸들링할 때 항상 IllegalArgumentException 가 발생해서 단순히 이번에도 그렇게 처리했던건데 제가 미처 생각지 못한 부분이네요!! 일관성 있게 해당 에러를 던지는 것으로 수정해볼게요 감사합니당
private final UserService userService; | ||
|
||
@PostMapping("/user") | ||
public String register(@RequestBody final RequestDto request) { |
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.
RequestDto를 받아올 때 final 키워드와 함께 받아오는 부분 좋아보이네요 참고하겠습니다~!!
import lombok.ToString; | ||
import sopt.org.SecondSeminar.domain.post.Post; | ||
|
||
@ToString |
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.
@tostring 어노테이션도 있군요! 배워갑니다👍
📝 관련 이슈
closed #6
👩🏻💻 내용
😸 중점을 둔 부분
중간에 커밋이 꼬여서 다시 올렸어요 ㅠㅡㅠ