Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /tyvekzhang_fastlib /fastlib /exception /base.py
| # SPDX-License-Identifier: MIT | |
| """Base exception class for the application.""" | |
| from http import HTTPStatus | |
| from typing import Any | |
| from pydantic import BaseModel | |
| class ErrorDetail(BaseModel): | |
| """Error detail.""" | |
| code: int | |
| message: str | |
| class BaseException(Exception): | |
| """ | |
| Base exception class for all custom exception in the application. | |
| Attributes: | |
| code: The code enum member from BaseErrorCode or its subclasses. | |
| message: Optional additional message about the error. | |
| details: Optional extra error details. | |
| """ | |
| def __init__( | |
| self, | |
| code: ErrorDetail, | |
| message: str | None = None, | |
| details: Any | None = None, | |
| ): | |
| """ | |
| Initialize the HTTPException. | |
| Args: | |
| code: The error code enum member. | |
| message: Optional additional message about the error. | |
| details: Optional extra error details. | |
| """ | |
| self.code = code | |
| self.message = message | |
| self.details = details | |
| self.__post_init__() | |
| def __post_init__(self): | |
| if self.message is None: | |
| self.message = self.code.message | |
| class SystemErrorCode: | |
| """System-related error codes.""" | |
| INTERNAL_ERROR = ErrorDetail( | |
| code=HTTPStatus.INTERNAL_SERVER_ERROR.value, message="Internal server error" | |
| ) | |
| class SystemException(BaseException): | |
| code: SystemErrorCode | |
| message: str | None = None | |
| details: Any | None = None | |
Xet Storage Details
- Size:
- 1.49 kB
- Xet hash:
- bbd325dd0c2b6c112cb4ac63cd4488d838144ebe66b17cc4eb9b92793e78a384
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.