StegaPy基础异常类
| 4 | |
| 5 | |
| 6 | class StegaPyException(Exception): |
| 7 | """StegaPy基础异常类""" |
| 8 | |
| 9 | UNHANDLED_EXCEPTION = "UNHANDLED_EXCEPTION" |
| 10 | |
| 11 | def __init__(self, message=None, error_code=None, namespace=None, *args): |
| 12 | """初始化异常""" |
| 13 | self.error_code = error_code or self.UNHANDLED_EXCEPTION |
| 14 | self.namespace = namespace |
| 15 | self.args = args |
| 16 | |
| 17 | if message: |
| 18 | self.message = message |
| 19 | else: |
| 20 | self.message = f"StegaPy错误: {self.error_code}" |
| 21 | if args: |
| 22 | self.message += f" - {', '.join(str(a) for a in args)}" |
| 23 | |
| 24 | super().__init__(self.message) |
| 25 | |
| 26 | def get_error_code(self): |
| 27 | """获取错误代码""" |
| 28 | return self.error_code |
| 29 | |
| 30 | def get_namespace(self): |
| 31 | """获取命名空间""" |
| 32 | return self.namespace |
| 33 | |
| 34 | |
| 35 | class StegaPyErrors: |
no outgoing calls
no test coverage detected