-
Notifications
You must be signed in to change notification settings - Fork 7
[6. 에러 핸들링] 권용현 과제 제출합니다. #68
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: yonghyun
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.landvibe.landlog.exception; | ||
|
|
||
| public class BlogNotFoundException extends RuntimeException { | ||
|
|
||
| private String message; | ||
|
|
||
| public BlogNotFoundException(String message) { | ||
| this.message = message; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.landvibe.landlog.exception; | ||
|
|
||
| public class LoginFailException extends RuntimeException { | ||
|
|
||
| private String message; | ||
|
|
||
| public LoginFailException(String message) { | ||
| this.message = message; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package com.landvibe.landlog.exception; | ||
|
|
||
| public class MemberNotFoundException extends RuntimeException { | ||
|
|
||
| private String message; | ||
|
|
||
| public MemberNotFoundException(String message) { | ||
| this.message = message; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.landvibe.landlog.support; | ||
|
|
||
| import com.landvibe.landlog.exception.LoginFailException; | ||
| import com.landvibe.landlog.exception.MemberNotFoundException; | ||
| import org.springframework.http.HttpStatus; | ||
| import org.springframework.web.bind.annotation.ControllerAdvice; | ||
| import org.springframework.web.bind.annotation.ExceptionHandler; | ||
| import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| @ControllerAdvice | ||
| @ResponseStatus(HttpStatus.BAD_REQUEST) | ||
| public class ControllerSupport { | ||
|
Comment on lines
+12
to
+14
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 모든 예외상황을 |
||
|
|
||
| @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()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sout으로 로그를 남기는 것은 지양해야합니다. |
||
| return "members/createMemberForm"; | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
Comment on lines
+12
to
+29
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restful한 API가 아니게 되어버렸네요. axios가 생소하더라도 html을 수정해보세요 :) |
||
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.
예외 메시지도 따로 분리할 수 있어보이네요.