Skip to content
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

[6. 에러 핸들링] 권용현 과제 제출합니다. #68

Open
wants to merge 1 commit into
base: yonghyun
Choose a base branch
from

Conversation

kwonyonghyun
Copy link

No description provided.

Comment on lines +12 to +29
@ControllerAdvice
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class ControllerSupport {

@ExceptionHandler({MemberNotFoundException.class, LoginFailException.class})
public String handle(RuntimeException e) {
System.out.println(e.getMessage());
return "home";
}

@ExceptionHandler(IllegalStateException.class)
public String handle(IllegalStateException e) {
System.out.println(e.getMessage());
return "members/createMemberForm";
}


}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restful한 API가 아니게 되어버렸네요. axios가 생소하더라도 html을 수정해보세요 :)


@ExceptionHandler(IllegalStateException.class)
public String handle(IllegalStateException e) {
System.out.println(e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sout으로 로그를 남기는 것은 지양해야합니다.

Comment on lines +12 to +14
@ControllerAdvice
@ResponseStatus(HttpStatus.BAD_REQUEST)
public class ControllerSupport {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

모든 예외상황을 BAD REQUEST로 처리해야할까요?


public Member login(LoginForm form) {
String email = form.getEmail();
String password = form.getPassword();
Optional<Member> optionalMember = memberRepository.findByEmailAndPassword(email, password);
return optionalMember.orElseThrow(() -> new IllegalStateException("이메일, 비밀번호가 일치하는 회원이 존재하지 않습니다"));
return optionalMember.orElseThrow(() -> new LoginFailException("이메일, 비밀번호가 일치하는 회원이 존재하지 않습니다"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예외 메시지도 따로 분리할 수 있어보이네요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants