class AlexError(Exception): def __init__(self, msg): self.message = msg # def __str__(self): # return ‘sdfsf‘try: raise AlexError(‘数据库连不上‘)except AlexError as e: print(e)
自定义异常
原文:https://www.cnblogs.com/rongye/p/9967949.html