python 自定义异常

class CustomException(exceptions.Exception):
	def __init__(self, error_info):
		Exception.__init__(self, error_info)
		self.error = error_info

	def __str__(self):
		return self.error


try:
  xx
except:
  raise CustomException("自定义报错。。。。。。")

  

猜你喜欢

转载自www.cnblogs.com/chenadong/p/9935775.html