Skip to content

Commit

Permalink
feat: 유저 인증 관련 UnAuthorizedException Handler 구현 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
PgmJun committed Jan 23, 2024
1 parent fb51f8b commit 40906f0
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.nice.petudio.common.exception.model.ForbiddenException;
import com.nice.petudio.common.exception.model.InternalServerException;
import com.nice.petudio.common.exception.model.NotFoundException;
import com.nice.petudio.common.exception.model.UnAuthorizedException;
import com.nice.petudio.common.exception.model.ValidationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -71,6 +72,17 @@ protected ApiResponse<Object> handleInvalidFormatException(final Exception excep
return ApiResponse.error(ErrorCode.BAD_REQUEST_EXCEPTION);
}

/**
* 401 UnAuthorized
*/
// 회원 인증에 실패했을 경우 발생
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(UnAuthorizedException.class)
protected ApiResponse<Object> handleUnAuthorizedException(
UnAuthorizedException exception) {
log.error(exception.getMessage(), exception);
return ApiResponse.error(exception.getErrorCode());
}

/**
* 403 Forbidden
Expand Down

0 comments on commit 40906f0

Please sign in to comment.