class CustomError(Exception):
def init(self,ErrorInfo):
super().init(self) #初始化父类
self.errorinfo=ErrorInfo
def str(self):
return self.errorinfo
if name == ‘main’:
try:
raise CustomError(‘客户异常’)
except CustomError as e:
print(e)
08-23
231
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)