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)