-
Notifications
You must be signed in to change notification settings - Fork 7
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
base: yonghyun
Are you sure you want to change the base?
Conversation
@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"; | ||
} | ||
|
||
|
||
} |
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.
Restful한 API가 아니게 되어버렸네요. axios가 생소하더라도 html을 수정해보세요 :)
|
||
@ExceptionHandler(IllegalStateException.class) | ||
public String handle(IllegalStateException e) { | ||
System.out.println(e.getMessage()); |
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.
sout으로 로그를 남기는 것은 지양해야합니다.
@ControllerAdvice | ||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public class ControllerSupport { |
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.
모든 예외상황을 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("이메일, 비밀번호가 일치하는 회원이 존재하지 않습니다")); |
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.
예외 메시지도 따로 분리할 수 있어보이네요.
No description provided.