Spaces:
Running
Running
Download services/ocr/errors.py from flakego/image-services-lama: direct link, hf CLI and curl.
- Browser
- Download file 744 Bytes
-
https://huggingface.co/spaces/flakego/image-services-lama/resolve/main/services/ocr/errors.py
- Command line
-
hf download hf://spaces/flakego/image-services-lama/services/ocr/errors.py
-
curl -L -o errors.py https://huggingface.co/spaces/flakego/image-services-lama/resolve/main/services/ocr/errors.py
744 Bytes
| from __future__ import annotations | |
| from typing import Any | |
| class OCRServiceError(Exception): | |
| """可预期、可返回给调用方的服务错误。""" | |
| def __init__( | |
| self, | |
| code: str, | |
| message: str, | |
| *, | |
| status_code: int = 400, | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message) | |
| self.code = code | |
| self.message = message | |
| self.status_code = status_code | |
| self.details = details | |
| def as_dict(self) -> dict[str, Any]: | |
| error: dict[str, Any] = {"code": self.code, "message": self.message} | |
| if self.details is not None: | |
| error["details"] = self.details | |
| return error | |