diff --git a/src/application/domain/exceptions/__init__.py b/src/application/domain/exceptions/__init__.py index 03368ee..e882cff 100644 --- a/src/application/domain/exceptions/__init__.py +++ b/src/application/domain/exceptions/__init__.py @@ -1,11 +1,9 @@ -from src.application.domain.exceptions.application_exceptions import ( - ApplicationException, - BadRequestException, - ConflictException, - ForbiddenException, - InternalException, - NotFoundException, - ServiceUnavailableException, - TooManyRequestsException, - UnauthorizedException, -) +from src.application.domain.exceptions.application_exceptions import ApplicationException +from src.application.domain.exceptions.bad_request_exception import BadRequestException +from src.application.domain.exceptions.unauthorized_exception import UnauthorizedException +from src.application.domain.exceptions.forbidden_exception import ForbiddenException +from src.application.domain.exceptions.not_found_exception import NotFoundException +from src.application.domain.exceptions.conflict_exception import ConflictException +from src.application.domain.exceptions.internal_exception import InternalException +from src.application.domain.exceptions.service_unavailable_exception import ServiceUnavailableException +from src.application.domain.exceptions.too_many_requests_exception import TooManyRequestsException diff --git a/src/application/domain/exceptions/application_exceptions.py b/src/application/domain/exceptions/application_exceptions.py index 03cecd3..4892289 100644 --- a/src/application/domain/exceptions/application_exceptions.py +++ b/src/application/domain/exceptions/application_exceptions.py @@ -17,43 +17,3 @@ class ApplicationException(Exception): def __str__(self) -> str: return f'{self.status_code}: {self.message}' - - -class BadRequestException(ApplicationException): - def __init__(self, message: str, headers: Mapping[str, str] | None = None): - super().__init__(400, message, headers) - - -class UnauthorizedException(ApplicationException): - def __init__(self, message: str = 'Unauthorized', headers: Mapping[str, str] | None = None): - super().__init__(401, message, headers) - - -class ForbiddenException(ApplicationException): - def __init__(self, message: str = 'Forbidden', headers: Mapping[str, str] | None = None): - super().__init__(403, message, headers) - - -class NotFoundException(ApplicationException): - def __init__(self, message: str = 'Not found', headers: Mapping[str, str] | None = None): - super().__init__(404, message, headers) - - -class ConflictException(ApplicationException): - def __init__(self, message: str, headers: Mapping[str, str] | None = None): - super().__init__(409, message, headers) - - -class TooManyRequestsException(ApplicationException): - def __init__(self, message: str, headers: Mapping[str, str] | None = None): - super().__init__(429, message, headers) - - -class ServiceUnavailableException(ApplicationException): - def __init__(self, message: str, headers: Mapping[str, str] | None = None): - super().__init__(503, message, headers) - - -class InternalException(ApplicationException): - def __init__(self, message: str = 'Internal Server Error', headers: Mapping[str, str] | None = None): - super().__init__(500, message, headers) diff --git a/src/application/domain/exceptions/bad_request_exception.py b/src/application/domain/exceptions/bad_request_exception.py new file mode 100644 index 0000000..a55bcec --- /dev/null +++ b/src/application/domain/exceptions/bad_request_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class BadRequestException(ApplicationException): + def __init__(self, message: str, headers: Mapping[str, str] | None = None): + super().__init__(400, message, headers) diff --git a/src/application/domain/exceptions/conflict_exception.py b/src/application/domain/exceptions/conflict_exception.py new file mode 100644 index 0000000..462dfc7 --- /dev/null +++ b/src/application/domain/exceptions/conflict_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class ConflictException(ApplicationException): + def __init__(self, message: str, headers: Mapping[str, str] | None = None): + super().__init__(409, message, headers) diff --git a/src/application/domain/exceptions/forbidden_exception.py b/src/application/domain/exceptions/forbidden_exception.py new file mode 100644 index 0000000..fb561c4 --- /dev/null +++ b/src/application/domain/exceptions/forbidden_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class ForbiddenException(ApplicationException): + def __init__(self, message: str = 'Forbidden', headers: Mapping[str, str] | None = None): + super().__init__(403, message, headers) diff --git a/src/application/domain/exceptions/internal_exception.py b/src/application/domain/exceptions/internal_exception.py new file mode 100644 index 0000000..6b34899 --- /dev/null +++ b/src/application/domain/exceptions/internal_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class InternalException(ApplicationException): + def __init__(self, message: str = 'Internal Server Error', headers: Mapping[str, str] | None = None): + super().__init__(500, message, headers) diff --git a/src/application/domain/exceptions/not_found_exception.py b/src/application/domain/exceptions/not_found_exception.py new file mode 100644 index 0000000..2fb4a43 --- /dev/null +++ b/src/application/domain/exceptions/not_found_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class NotFoundException(ApplicationException): + def __init__(self, message: str = 'Not found', headers: Mapping[str, str] | None = None): + super().__init__(404, message, headers) diff --git a/src/application/domain/exceptions/service_unavailable_exception.py b/src/application/domain/exceptions/service_unavailable_exception.py new file mode 100644 index 0000000..8d6c7ab --- /dev/null +++ b/src/application/domain/exceptions/service_unavailable_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class ServiceUnavailableException(ApplicationException): + def __init__(self, message: str, headers: Mapping[str, str] | None = None): + super().__init__(503, message, headers) diff --git a/src/application/domain/exceptions/too_many_requests_exception.py b/src/application/domain/exceptions/too_many_requests_exception.py new file mode 100644 index 0000000..adf2a16 --- /dev/null +++ b/src/application/domain/exceptions/too_many_requests_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class TooManyRequestsException(ApplicationException): + def __init__(self, message: str, headers: Mapping[str, str] | None = None): + super().__init__(429, message, headers) diff --git a/src/application/domain/exceptions/unauthorized_exception.py b/src/application/domain/exceptions/unauthorized_exception.py new file mode 100644 index 0000000..a92fd35 --- /dev/null +++ b/src/application/domain/exceptions/unauthorized_exception.py @@ -0,0 +1,8 @@ +from application.domain.exceptions.application_exceptions import ApplicationException + +from typing import Mapping + + +class UnauthorizedException(ApplicationException): + def __init__(self, message: str = 'Unauthorized', headers: Mapping[str, str] | None = None): + super().__init__(401, message, headers)