mirror of
http://88.130.71.182:3000/BlitTech/deals24togo_be.git
synced 2026-06-12 23:33:21 +00:00
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
"""Application-level exceptions with HTTP status codes."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class AppException(Exception):
|
|
def __init__(self, status_code: int, detail: str):
|
|
self.status_code = status_code
|
|
self.detail = detail
|
|
super().__init__(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 = "Not enough permissions"):
|
|
super().__init__(status_code=403, detail=detail)
|
|
|
|
|
|
class BadRequestException(AppException):
|
|
def __init__(self, detail: str = "Bad request"):
|
|
super().__init__(status_code=400, detail=detail)
|
|
|
|
|
|
class ConflictException(AppException):
|
|
def __init__(self, detail: str = "Resource already exists"):
|
|
super().__init__(status_code=409, detail=detail)
|