refactor error handler
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from typing import TYPE_CHECKING, Final
|
||||
|
||||
from delta_barth.constants import DEFAULT_INTERNAL_ERR_CODE
|
||||
from delta_barth.types import DataPipelineErrors, doptResponseError
|
||||
from delta_barth.types import DataPipelineErrors, doptResponse
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from delta_barth.types import ErrorDescription
|
||||
@@ -33,7 +33,7 @@ DATA_PIPELINE_ERRORS_DESCR: Final[tuple[ErrorDescription, ...]] = (
|
||||
)
|
||||
|
||||
|
||||
class ErrorManager:
|
||||
class ErrorHandler:
|
||||
def __init__(self) -> None:
|
||||
self._data_pipelines: DataPipelineErrors | None = None
|
||||
self._parse_data_pipeline_errors()
|
||||
@@ -48,9 +48,9 @@ class ErrorManager:
|
||||
def _parse_data_pipeline_errors(self) -> None:
|
||||
if self._data_pipelines is not None:
|
||||
return
|
||||
parsed_errors: dict[str, doptResponseError] = {}
|
||||
parsed_errors: dict[str, doptResponse] = {}
|
||||
for err in DATA_PIPELINE_ERRORS_DESCR:
|
||||
parsed_errors[err[0]] = doptResponseError(status_code=err[1], description=err[2])
|
||||
parsed_errors[err[0]] = doptResponse(status_code=err[1], description=err[2])
|
||||
|
||||
self._data_pipelines = DataPipelineErrors(**parsed_errors)
|
||||
|
||||
@@ -59,8 +59,8 @@ class ErrorManager:
|
||||
description: str,
|
||||
message: str = "",
|
||||
err_code: int = DEFAULT_INTERNAL_ERR_CODE,
|
||||
) -> doptResponseError:
|
||||
return doptResponseError(
|
||||
) -> doptResponse:
|
||||
return doptResponse(
|
||||
status_code=err_code,
|
||||
description=description,
|
||||
message=message,
|
||||
|
||||
Reference in New Issue
Block a user