32 lines
1.4 KiB
Python
32 lines
1.4 KiB
Python
from fastapi import HTTPException, status
|
|
|
|
class AuthenticationError(HTTPException):
|
|
"""인증 오류"""
|
|
def __init__(self, detail: str = "인증에 실패했습니다"):
|
|
super().__init__(status_code=status.HTTP_401_UNAUTHORIZED, detail=detail)
|
|
|
|
class PermissionDeniedError(HTTPException):
|
|
"""권한 부족 오류"""
|
|
def __init__(self, detail: str = "권한이 없습니다"):
|
|
super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail)
|
|
|
|
class NotFoundError(HTTPException):
|
|
"""리소스를 찾을 수 없음"""
|
|
def __init__(self, detail: str = "리소스를 찾을 수 없습니다"):
|
|
super().__init__(status_code=status.HTTP_404_NOT_FOUND, detail=detail)
|
|
|
|
class BadRequestError(HTTPException):
|
|
"""잘못된 요청"""
|
|
def __init__(self, detail: str = "잘못된 요청입니다"):
|
|
super().__init__(status_code=status.HTTP_400_BAD_REQUEST, detail=detail)
|
|
|
|
class ConflictError(HTTPException):
|
|
"""충돌 오류 (중복 등)"""
|
|
def __init__(self, detail: str = "이미 존재하는 리소스입니다"):
|
|
super().__init__(status_code=status.HTTP_409_CONFLICT, detail=detail)
|
|
|
|
class InternalServerError(HTTPException):
|
|
"""서버 내부 오류"""
|
|
def __init__(self, detail: str = "서버 오류가 발생했습니다"):
|
|
super().__init__(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=detail)
|