diff --git a/adapter/docker/runtime.py b/adapter/docker/runtime.py index 7806bff..d9a6ec9 100644 --- a/adapter/docker/runtime.py +++ b/adapter/docker/runtime.py @@ -94,11 +94,11 @@ class DockerSandboxRuntime(SandboxRuntime): endpoint = self._endpoint_from_container(container) except (DockerException, OSError, ValueError) as exc: self._remove_created_container(container, str(chat_id), exc) - raise SandboxStartError(str(chat_id)) from exc + raise SandboxStartError(str(chat_id), str(exc)) from exc except SandboxStartError: raise except (DockerException, OSError, ValueError) as exc: - raise SandboxStartError(str(chat_id)) from exc + raise SandboxStartError(str(chat_id), str(exc)) from exc result = 'created' span.set_attribute('container.id', container_id) diff --git a/adapter/http/fastapi/routers/v1/router.py b/adapter/http/fastapi/routers/v1/router.py index 1d0616b..cb71748 100644 --- a/adapter/http/fastapi/routers/v1/router.py +++ b/adapter/http/fastapi/routers/v1/router.py @@ -70,9 +70,10 @@ def create_sandbox( detail=str(exc), ) from exc except SandboxStartError as exc: + detail = f'{exc}: {exc.reason}' if exc.reason else str(exc) raise HTTPException( status_code=status.HTTP_503_SERVICE_UNAVAILABLE, - detail=str(exc), + detail=detail, ) from exc except SandboxError as exc: raise HTTPException( diff --git a/domain/error.py b/domain/error.py index 2bd2cc5..ca3a143 100644 --- a/domain/error.py +++ b/domain/error.py @@ -23,9 +23,10 @@ class SandboxError(DomainError): class SandboxStartError(SandboxError): - def __init__(self, chat_id: str) -> None: + def __init__(self, chat_id: str, reason: str = '') -> None: super().__init__('sandbox_start_failed') self.chat_id = chat_id + self.reason = reason class SandboxAlreadyRunningError(SandboxError):