✨ feat(vscode): 代码阅读加异常卡片,Python、TypeScript 的异常类画成同一张表(属性、构造参数),方法照常是子块
This commit is contained in:
1 parent
d5a092dd6f
commit
0afd012c94
21 files changed
+1118
-66
No files matched your search
@@ -0,0 +1,75 @@
|
||||
"""commerce 域异常体系."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
class CommerceError(Exception):
|
||||
"""commerce 域基础异常."""
|
||||
|
||||
|
||||
class ProductNotFoundError(CommerceError):
|
||||
"""商品不存在或已下架."""
|
||||
|
||||
|
||||
class OrderNotFoundError(CommerceError):
|
||||
"""订单不存在."""
|
||||
|
||||
|
||||
class InvalidOrderStateError(CommerceError):
|
||||
"""订单状态非法转换."""
|
||||
|
||||
|
||||
class PaymentVerifyError(CommerceError):
|
||||
"""支付通道验签失败."""
|
||||
|
||||
|
||||
class AmountMismatchError(CommerceError):
|
||||
"""支付金额与订单金额不匹配."""
|
||||
|
||||
|
||||
class FulfillmentError(CommerceError):
|
||||
"""fulfillment 调 billing 失败."""
|
||||
|
||||
|
||||
class RefundError(CommerceError):
|
||||
"""退款失败."""
|
||||
|
||||
|
||||
class UnsupportedPaymentMethodError(CommerceError):
|
||||
"""未配置当前 payment_method 对应的 driver. 通常意味着环境变量缺失."""
|
||||
|
||||
def __init__(self, method: str) -> None:
|
||||
super().__init__(f"unsupported payment method: {method}")
|
||||
self.method = method
|
||||
|
||||
|
||||
class OutOfStockError(CommerceError):
|
||||
"""商品库存不足, 无法下单。"""
|
||||
|
||||
|
||||
class PurchaseLimitExceededError(CommerceError):
|
||||
"""超出商品 purchase_limit_per_user 限购次数。"""
|
||||
|
||||
|
||||
class PendingOrderExistsError(CommerceError):
|
||||
"""同一用户已有相同商品的待支付订单。"""
|
||||
|
||||
|
||||
class ProductPlanMissingError(CommerceError):
|
||||
"""商品未绑定任何 billing.Plan, 无法下单/履约。"""
|
||||
|
||||
|
||||
class InstanceTypeNotFoundError(CommerceError):
|
||||
"""instance_type_id 指向的档位不存在; admin 应回 400 而不是撞 FK 500。"""
|
||||
|
||||
def __init__(self, instance_type_id: int) -> None:
|
||||
super().__init__(f"instance_type {instance_type_id} not found")
|
||||
self.instance_type_id = instance_type_id
|
||||
|
||||
|
||||
class ProductPlanMismatchError(CommerceError):
|
||||
"""商品展示档位与 Billing Plan 实际发放档位不一致."""
|
||||
|
||||
|
||||
class WechatPayUnknownError(CommerceError):
|
||||
"""微信预下单结果未知: 网络中断/超时, 不能判定远端是否已受理."""
|
||||
Reference in new issue
Block a user