节点异常错误类型。节点遇到异常时,需要抛出NodeError,指定code, msg和data:: raise NodeError(200, u"node error msg", u"其他补充详细信息")
| 17 | |
| 18 | |
| 19 | class NodeError(Exception): |
| 20 | """ |
| 21 | 节点异常错误类型。节点遇到异常时,需要抛出NodeError,指定code, msg和data:: |
| 22 | |
| 23 | raise NodeError(200, u"node error msg", u"其他补充详细信息") |
| 24 | """ |
| 25 | def __init__(self, code, msg, data = None): |
| 26 | """ |
| 27 | :param code: 异常代码 |
| 28 | :param msg: 异常消息 |
| 29 | :param data: 详细信息 |
| 30 | """ |
| 31 | self.code = code |
| 32 | self.msg = msg |
| 33 | self.data = data |
| 34 | |
| 35 | def __str__(self): |
| 36 | return "Error[%d]: %s" % (self.code, self.msg) # python3 中不需要unicode |
| 37 | |
| 38 | class TaskError(NodeError): |
| 39 | """ |
no outgoing calls
no test coverage detected