/
mainframe
/
Intellectuality_task_manager
Обзор
Документация
Войти
/
mainframe
/
Intellectuality_task_manager
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/app/exceptions.py
70 строк
2 KB
Ivan
initial commit
14 апр 2026, 17:18
14 апр 2026, 17:18
d3c4609
Код
Авторство
О чём код?
# path: backend/app/exceptions.py from typing import Any class AppException(Exception): """ Базовое прикладное исключение. """ def __init__( self, status_code: int, code: str, message: str, details: Any | None = None, ) -> None: super().__init__(message) self.status_code = status_code self.code = code self.message = message self.details = details class NotFoundException(AppException): """ Исключение для 404. """ def __init__(self, message: str = "Ресурс не найден.") -> None: super().__init__( status_code=404, code="not_found", message=message, ) class BadRequestException(AppException): """ Исключение для 400. """ def __init__( self, message: str = "Некорректный запрос.", details: Any | None = None, ) -> None: super().__init__( status_code=400, code="bad_request", message=message, details=details, ) class ExternalServiceException(AppException): """ Исключение для ошибок внешних сервисов. """ def __init__( self, message: str = "Ошибка внешнего сервиса.", details: Any | None = None, ) -> None: super().__init__( status_code=502, code="external_service_error", message=message, details=details, )