def delete_task_error_handler(result: Result) -> HttpError:
    domain_error = result.value
    http_error = HttpError()
    if isinstance(domain_error, TaskNotFoundError):
        http_error.message = "Task not found"
        http_error.code = 404
        http_error.type_error = "TaskNotFoundError"
    return http_error
Ejemplo n.º 2
0
def get_task_error_handler(result: Result) -> HttpError:
    domain_error = result.value
    http_error = HttpError()
    if isinstance(domain_error, TaskNotFoundError):
        http_error.message = "Task not found"
        http_error.code = 404
        http_error.type_error = "TaskNotFoundError"
    elif isinstance(domain_error, InvalidUuidError):
        http_error.message = "Invalid TaskId. TaskId must be a valid 36-char UUID"
        http_error.code = 400
        http_error.type_error = "InvalidTaskIdError"
    return http_error
Ejemplo n.º 3
0
    def __init__(self, result: Result):
        self.domain_error = result.value

        self.http_error = HttpError()
        self.is_a_result_known_error = False
        domain_error = result.value

        if isinstance(domain_error, InvalidTokenError):
            self.http_error = InvalidTokenHttpError(
                suffix=domain_error.message)
            self.is_a_result_known_error = True
Ejemplo n.º 4
0
from petisco.event.shared.domain.request_responded import RequestResponded
from petisco.frameworks.flask.flask_headers_provider import flask_headers_provider
from petisco.logger.interface_logger import ERROR, DEBUG
from petisco.controller.errors.http_error import HttpError
from petisco.notifier.domain.interface_notifier import INotifier
from petisco.notifier.domain.notifier_exception_message import NotifierExceptionMessage
from petisco.security.token_manager.not_implemented_token_manager import (
    NotImplementedTokenManager,
)
from petisco.security.token_manager.token_manager import TokenManager
from petisco.logger.log_message import LogMessage
from petisco.tools.timer import timer

DEFAULT_SUCCESS_MESSAGE = {"message": "OK"}, 200
DEFAULT_ERROR_MESSAGE = HttpError().handle()
DEFAULT_APP_NAME = "app-undefined"
DEFAULT_APP_VERSION = "version-undefined"
DEFAULT_LOGGER = None
DEFAULT_EVENT_BUS = None
DEFAULT_NOTIFIER = None


class _ControllerHandler:
    def __init__(
        self,
        app_name: str = DEFAULT_ERROR_MESSAGE,
        app_version: str = DEFAULT_APP_VERSION,
        logger=DEFAULT_LOGGER,
        notifier: INotifier = DEFAULT_NOTIFIER,
        token_manager: TokenManager = NotImplementedTokenManager(),
Ejemplo n.º 5
0
def error_handler(result: Result) -> HttpError:
    domain_error = result.value
    http_error = HttpError()
    if isinstance(domain_error, PersistenceError):
        http_error = PersistenceHttpError()
    return http_error
Ejemplo n.º 6
0
def error_handler(result: Result) -> HttpError:
    domain_error = result.value
    http_error = HttpError()
    if isinstance(domain_error, EnvironmentProviderError):
        http_error = EnvironmentProviderHttpError()
    return http_error