-
Notifications
You must be signed in to change notification settings - Fork 7
[BE] refactor: 예외 메시지 포맷 수정 #263
Changes from 12 commits
2d7d596
de928c2
3a993c1
9dbeffa
d6b45f4
9fe901d
bad5d38
c8d7ddb
6103dfd
61591b9
95ddf93
e34b655
cf2bdb0
cecaa79
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,18 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class AuthorizationHeaderNotFoundException extends AuthenticationException { | ||
public AuthorizationHeaderNotFoundException() { | ||
super(null); | ||
} | ||
|
||
public AuthorizationHeaderNotFoundException(final Throwable cause) { | ||
super(null, cause); | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "Authorization 해더값이 존재하지 않습니다."; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class ExpiredTokenException extends AuthenticationException { | ||
private static final String MESSAGE = "유효하지 않은 토큰입니다."; | ||
|
||
public ExpiredTokenException() { | ||
super(MESSAGE); | ||
} | ||
|
||
public ExpiredTokenException(final Throwable cause) { | ||
super(MESSAGE, cause); | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "AccessToken이 만료되었습니다. RefreshToken값을 요청하세요."; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class InvalidAuthorizationHeaderTypeException extends AuthenticationException { | ||
private final String authorizationHeader; | ||
|
||
public InvalidAuthorizationHeaderTypeException(final String authorizationHeader) { | ||
super(null); | ||
this.authorizationHeader = authorizationHeader; | ||
} | ||
|
||
public InvalidAuthorizationHeaderTypeException(final String authorizationHeader, final Throwable cause) { | ||
super(null, cause); | ||
this.authorizationHeader = authorizationHeader; | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "Authorization 헤더의 타입이 올바르지 않습니다. 입력한 헤더: " + authorizationHeader; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class InvalidRefreshTokenException extends AuthenticationException { | ||
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. 유효하지 않은 RefreshToken 이라는게 만료되었다는 건가요 !? 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. 현재 두 가지 상황에서 사용되고 있네요! 두 가지 상황을 분리하여 예외를 던지는 것이 좋을까요? 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. Member로부터 찾은 그렇다면 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.
맞아요! |
||
public InvalidRefreshTokenException() { | ||
super(null); | ||
} | ||
|
||
public InvalidRefreshTokenException(final Throwable cause) { | ||
super(null, cause); | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "유효하지 않은 RefreshToken입니다. 다시 로그인을 진행하세요."; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class NoRefreshTokenInCookieException extends AuthenticationException { | ||
public NoRefreshTokenInCookieException() { | ||
super(null); | ||
} | ||
|
||
public NoRefreshTokenInCookieException(final Throwable cause) { | ||
super(null, cause); | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "쿠키에 RefreshToken이 존재하지 않습니다."; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.donggle.backend.auth.exception; | ||
|
||
import org.donggle.backend.exception.authentication.AuthenticationException; | ||
|
||
public class RefreshTokenNotFoundException extends AuthenticationException { | ||
public RefreshTokenNotFoundException() { | ||
super(null); | ||
} | ||
|
||
public RefreshTokenNotFoundException(final Throwable cause) { | ||
super(null, cause); | ||
} | ||
|
||
@Override | ||
public String getHint() { | ||
return "존재하지 않는 토큰입니다. 다시 로그인을 진행하세요."; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
package org.donggle.backend.exception.authentication; | ||
|
||
import org.springframework.http.HttpStatus; | ||
|
||
public abstract class AuthenticationException extends RuntimeException { | ||
public AuthenticationException(final String message) { | ||
super(message); | ||
} | ||
|
||
public AuthenticationException(final String message, final Throwable cause) { | ||
super(message, cause); | ||
} | ||
|
||
public abstract String getHint(); | ||
|
||
public final int getErrorCode() { | ||
return HttpStatus.UNAUTHORIZED.value(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,4 +8,8 @@ public BusinessException(final String message) { | |||||||||
public BusinessException(final String message, final Throwable cause) { | ||||||||||
super(message, cause); | ||||||||||
} | ||||||||||
|
||||||||||
public abstract String getHint(); | ||||||||||
|
||||||||||
public abstract int getErrorCode(); | ||||||||||
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.
Suggested change
는 어떨까요 ?! 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.
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.
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. 넵! 언젠가 커스텀 예외 코드를 사용할 일이 생기길!! |
||||||||||
} |
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.
이 부분은 MemberNotFoundException이 맞지 않을까 생각합니다. memberId로 memberRepository에서 Member를 찾아오는 걸로 보이네요!
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.
어라.. 그렇네요?! 에코 말 듣고보니까 전형적인
MemberNotFoundException
인데 시야가 좁아졌었나봅니다 ㅋㅋㅋ 땡큐 에코오