-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] #76 JWT Authorization과 관련된 예외를 처리하는 핸들러 구현
- Loading branch information
1 parent
21e3baa
commit 5bd846b
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...a/com/teamseven/MusicVillain/ExceptionHandler/GlobalJwtAuhtorizationExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.teamseven.MusicVillain.ExceptionHandler; | ||
|
||
import com.teamseven.MusicVillain.Dto.ResponseBody.ResponseObject; | ||
import com.teamseven.MusicVillain.Exception.JwtAuthorizationFailException; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
/** | ||
* @apiNote | ||
* JWT Authorization 관련 예외들을 처리하는 핸들러<br> | ||
* 모든 @Controller 또는 @RestController에서 발생하는 JWT 인증/인가 예외에 대한 핸들 메서드를 제공한다.<br> | ||
* @author Woody K | ||
*/ | ||
@Slf4j | ||
@ControllerAdvice | ||
public class GlobalJwtAuhtorizationExceptionHandler { | ||
/** | ||
* @apiNote | ||
* JwtAuthorizationFailException 발생 시 처리하기 위한 handle method | ||
* @return HTTP Status Code `UNAUTHORIZED(401)`와 실패 메시지를 담은 ResponseObject를 반환한다. | ||
* @author Woody K | ||
*/ | ||
@ExceptionHandler(JwtAuthorizationFailException.class) | ||
public ResponseObject JwtAuthorizationFailExceptionHandle(Exception e){ | ||
return ResponseObject.UNAUTHORIZED("Authorization failed"); | ||
} | ||
} |