- erpsdk:金蝶云星空(K3Cloud)WebAPI 通用 SDK——账套/组织/AppSecret 登录、 会话复用、单据查询与读写(Save/Submit/Audit/删除/下推/分配/工作流审批)、 分组维护、即时库存、报表取数(分页),内置新旧两套 ERP 站点 - printkit:网络打印机直连(IPP over TLS,无驱动无弹窗)——内置 EPSON L6570/L565,PDF/图片格式化、Excel·WPS 表格按列过滤排版分页、 Validate-Job 干跑校验、设备能力预检与参数降级 - 均按 SDK 形态供给:sdk.json / api.json / pyproject.toml / _selftest.py
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""printkit 异常体系。
|
||
|
||
插件侧统一 ``except PrintKitError`` 即可兜住全部失败,
|
||
细分类型用于决定是否重试(:class:`TransportError` 可重试)。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
|
||
class PrintKitError(Exception):
|
||
"""printkit 所有异常的基类。"""
|
||
|
||
|
||
class ConfigError(PrintKitError):
|
||
"""打印机清单配置非法(id 重复、字段缺失、文件不存在等)。"""
|
||
|
||
|
||
class PrinterNotFound(PrintKitError):
|
||
"""按 id 找不到打印机,且该值也不是可直连的地址。"""
|
||
|
||
|
||
class TransportError(PrintKitError):
|
||
"""网络/协议层失败(连不上、TLS 失败、HTTP 非 200、IPP 无响应)。
|
||
|
||
可安全重试。
|
||
"""
|
||
|
||
|
||
class IppError(PrintKitError):
|
||
"""打印机返回了 IPP 错误状态(非 0x0000/0x0001/0x0002)。
|
||
|
||
携带 ``status_code`` 与 ``status_text``,**不要盲目重试**。
|
||
"""
|
||
|
||
def __init__(self, status_code: int, status_text: str, operation: str = ""):
|
||
self.status_code = status_code
|
||
self.status_text = status_text
|
||
self.operation = operation
|
||
super().__init__(f"{operation or 'IPP'} 失败: 0x{status_code:04X} {status_text}")
|
||
|
||
|
||
class UnsupportedFormat(PrintKitError):
|
||
"""设备不支持要求的文档格式。"""
|