- assets/: sap-cli source (v2.1.0, 26 commands, 16 object types) - references/: tool constraints + error handling (self-contained) - scripts/setup.py: one-click install/config/verify - SKILL.md: full command reference + dual-platform install guide - VERSION: 2.1.0 Built from D:/Codespace/sap-cli via scripts/pack_skill.py
78 lines
1.8 KiB
Python
78 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
|
|
class SapCliError(Exception):
|
|
"""基础异常"""
|
|
|
|
|
|
class ConfigError(SapCliError):
|
|
"""配置错误(缺失参数、文件不存在等)"""
|
|
|
|
|
|
class LoginError(SapCliError):
|
|
"""登录失败"""
|
|
|
|
|
|
class ObjectNotFoundError(SapCliError):
|
|
"""对象不存在"""
|
|
|
|
def __init__(self, name: str, obj_type: str):
|
|
self.name = name
|
|
self.obj_type = obj_type
|
|
super().__init__(f"{obj_type} 对象不存在: {name}")
|
|
|
|
|
|
class ObjectAlreadyExistsError(SapCliError):
|
|
"""对象已存在"""
|
|
|
|
def __init__(self, name: str, obj_type: str):
|
|
self.name = name
|
|
self.obj_type = obj_type
|
|
super().__init__(f"{obj_type} 对象已存在: {name}")
|
|
|
|
|
|
class LockError(SapCliError):
|
|
"""锁定失败"""
|
|
|
|
def __init__(self, message: str, obj_uri: str = ""):
|
|
self.obj_uri = obj_uri
|
|
super().__init__(message)
|
|
|
|
|
|
class ActivationError(SapCliError):
|
|
"""激活失败"""
|
|
|
|
def __init__(self, message: str, errors: list[dict] | None = None):
|
|
self.errors = errors or []
|
|
super().__init__(message)
|
|
|
|
|
|
class SyntaxCheckError(SapCliError):
|
|
"""语法检查未通过"""
|
|
|
|
def __init__(self, message: str, errors: list[dict] | None = None, warnings: list[dict] | None = None):
|
|
self.errors = errors or []
|
|
self.warnings = warnings or []
|
|
super().__init__(message)
|
|
|
|
|
|
class DeleteError(SapCliError):
|
|
"""删除失败"""
|
|
|
|
|
|
class CreateError(SapCliError):
|
|
"""创建失败"""
|
|
|
|
|
|
class InvalidNameError(SapCliError):
|
|
"""对象名称格式错误"""
|
|
|
|
|
|
class CyclicDependencyError(SapCliError):
|
|
"""循环依赖(拓扑排序检测)"""
|
|
|
|
def __init__(self, cycle_members: list[str]):
|
|
self.cycle_members = cycle_members
|
|
members = " → ".join(cycle_members)
|
|
super().__init__(f"检测到循环依赖: {members}")
|