lavkach3
47 строк · 1.3 Кб
1from http import HTTPStatus2
3
4class CustomException(Exception):5code = HTTPStatus.BAD_GATEWAY6error_code = HTTPStatus.BAD_GATEWAY7message = HTTPStatus.BAD_GATEWAY.description8
9def __init__(self, message=None):10if message:11self.message = message12
13
14class BadRequestException(CustomException):15code = HTTPStatus.BAD_REQUEST16error_code = HTTPStatus.BAD_REQUEST17message = HTTPStatus.BAD_REQUEST.description18
19
20class NotFoundException(CustomException):21code = HTTPStatus.NOT_FOUND22error_code = HTTPStatus.NOT_FOUND23message = HTTPStatus.NOT_FOUND.description24
25
26class ForbiddenException(CustomException):27code = HTTPStatus.FORBIDDEN28error_code = HTTPStatus.FORBIDDEN29message = HTTPStatus.FORBIDDEN.description30
31
32class UnauthorizedException(CustomException):33code = HTTPStatus.UNAUTHORIZED34error_code = HTTPStatus.UNAUTHORIZED35message = HTTPStatus.UNAUTHORIZED.description36
37
38class UnprocessableEntity(CustomException):39code = HTTPStatus.UNPROCESSABLE_ENTITY40error_code = HTTPStatus.UNPROCESSABLE_ENTITY41message = HTTPStatus.UNPROCESSABLE_ENTITY.description42
43
44class DuplicateValueException(CustomException):45code = HTTPStatus.UNPROCESSABLE_ENTITY46error_code = HTTPStatus.UNPROCESSABLE_ENTITY47message = HTTPStatus.UNPROCESSABLE_ENTITY.description48