编写自定义异常代码,编译出错
在win7环境下编写以下代码并执行,结果出错,提示没有定义异常,但是代码里明明定义了啊?
求指导!!
代码:
class CustomError(Exception):
def __init__(self, info):
Exception.__init__(self)
self.errorinfo = info
print 'self.errorinfo'
def __str__(self):
return 'customError: %s'% self.error.info
try:
raise customError("test")
except customError, e:
print 'info:%s'%(e)