초기 커밋
This commit is contained in:
32
app/core/exceptions.py
Normal file
32
app/core/exceptions.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class AppException(Exception):
|
||||
def __init__(self, status_code: int, detail: str):
|
||||
self.status_code = status_code
|
||||
self.detail = detail
|
||||
|
||||
|
||||
class NotFoundException(AppException):
|
||||
def __init__(self, detail: str = "Resource not found"):
|
||||
super().__init__(status_code=404, detail=detail)
|
||||
|
||||
|
||||
class UnauthorizedException(AppException):
|
||||
def __init__(self, detail: str = "Not authenticated"):
|
||||
super().__init__(status_code=401, detail=detail)
|
||||
|
||||
|
||||
class ForbiddenException(AppException):
|
||||
def __init__(self, detail: str = "Permission denied"):
|
||||
super().__init__(status_code=403, detail=detail)
|
||||
|
||||
|
||||
class ConflictException(AppException):
|
||||
def __init__(self, detail: str = "Resource already exists"):
|
||||
super().__init__(status_code=409, detail=detail)
|
||||
|
||||
|
||||
class ValidationException(AppException):
|
||||
def __init__(self, detail: str = "Validation error"):
|
||||
super().__init__(status_code=422, detail=detail)
|
||||
Reference in New Issue
Block a user