test_zadanie_S3/app/exceptions.py
2024-03-23 14:09:12 +03:00

24 lines
679 B
Python

from fastapi import HTTPException, status
class S3Exception(HTTPException):
status_code = 500
detail = ""
def __init__(self):
super().__init__(status_code=self.status_code, detail=self.detail)
class IncorrectFileException(S3Exception):
status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
detail = "Неверный тип файла"
class BrokenFileException(S3Exception):
status_code = status.HTTP_422_UNPROCESSABLE_ENTITY
detail = "Битый файл"
class UnexpectedErrorException(S3Exception):
status_code = status.HTTP_500_INTERNAL_SERVER_ERROR
detail = "Произошла непредвиденная ошибка"