Files
gsfdc/demo-dify/dify/api/libs/exception.py
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

35 lines
1.1 KiB
Python

from collections.abc import Mapping
from typing import Any
from werkzeug.exceptions import HTTPException
class BaseHTTPException(HTTPException):
error_code: str = "unknown"
data: dict[str, Any] | None = None
def __init__(self, description=None, response=None):
super().__init__(description, response)
self.data = {
"code": self.error_code,
"message": self.description,
"status": self.code,
}
class RelayedHTTPError(BaseHTTPException):
"""An error whose ``code`` and status are relayed from a downstream service at runtime.
Emits the standard error body, but its codes cannot be listed per class. Declaring it
with ``error_responses`` keeps the operation's error codes and statuses open.
"""
def __init__(self, *, status: int, error_code: str, message: str, details: Mapping[str, Any] | None = None) -> None:
self.code = status
self.error_code = error_code
super().__init__(description=message)
if details:
assert self.data is not None
self.data["details"] = dict(details)