Skip to content

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로 처리해야할까요?

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