Skip to content

Commit

Permalink
[+] #76 JWT Authorization과 관련된 예외를 처리하는 핸들러 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
woody35545 committed Oct 5, 2023
1 parent 21e3baa commit 5bd846b
Showing 1 changed file with 28 additions and 0 deletions.
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");
}
}

0 comments on commit 5bd846b

Please sign in to comment.