80 lines
1.9 KiB
Python
80 lines
1.9 KiB
Python
# Copyright 2026 zhaoxi826
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
|
|
class RetryableError(Exception):
|
|
"""基类:所有可重试错误(如网络断开、抖动等临时性故障)。"""
|
|
|
|
pass
|
|
|
|
|
|
class NonRetryableError(Exception):
|
|
"""基类:所有不可重试错误(如数据验证失败、类型错误等业务逻辑故障)。"""
|
|
|
|
pass
|
|
|
|
|
|
class DemandError(NonRetryableError):
|
|
"""需求/任务参数不合法或不满足前置条件时抛出。"""
|
|
|
|
pass
|
|
|
|
|
|
class ModelNotExistError(Exception):
|
|
"""请求了一个未在 Provider 中注册的模型 ID 时抛出。"""
|
|
|
|
pass
|
|
|
|
|
|
class UserError(Exception):
|
|
"""用户相关错误的基类,HTTP 层会被统一映射为 4xx。"""
|
|
|
|
pass
|
|
|
|
|
|
class UserNotExistError(UserError):
|
|
"""按用户名/ID 查询时用户不存在。"""
|
|
|
|
pass
|
|
|
|
|
|
class UserPasswordError(UserError):
|
|
"""口令校验失败(旧密码错误、登录密码错误等)。"""
|
|
|
|
pass
|
|
|
|
|
|
class ProviderError(Exception):
|
|
"""模型 Provider 相关错误的基类。"""
|
|
|
|
pass
|
|
|
|
|
|
class ProviderNotExistError(ProviderError):
|
|
"""请求了一个未注册的 Provider 时抛出。"""
|
|
|
|
pass
|
|
|
|
|
|
class WorkflowError(Exception):
|
|
"""工作流执行期错误的基类,HTTP 层会被统一映射为 5xx。"""
|
|
|
|
pass
|
|
|
|
|
|
class WorkflowExit(WorkflowError):
|
|
"""工作流被显式终止(用户取消、上游决策跳出等)时抛出,是预期内的退出信号。"""
|
|
|
|
pass
|