Python学习详细异常信息

Posted Gtea

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python学习详细异常信息相关的知识,希望对你有一定的参考价值。

 

def robust(func):
    """
    异常追踪装饰器
    :param func:
    :return:
    """
    def add_robust(*args, **kwargs):
        try:
            previous_frame = inspect.currentframe().f_back
            caller_filename, caller_line_number, caller_function_name, caller_lines, caller_index = inspect.getframeinfo(
                previous_frame)
            LOG_DEBUG(caller_filename: {}, caller_line_number: {}, caller_function_name: {}.format(caller_filename,
                                                                                                 caller_line_number,
                                                                                                 caller_function_name))
            return func(*args, **kwargs)
        except Exception:
            LOG_ERROR(Error execute func:{}.format(func.__name__))
            traceback.print_exc()
    return add_robust
try:
    i = int(a)
except Exception, e:
    print str(Exception):	, str(Exception)
    print str(e):		, str(e)
    print repr(e):	, repr(e)
    print e.message:	, e.message
    print traceback.print_exc():; traceback.print_exc()
    print traceback.format_exc():
%s % traceback.format_exc()

 

以上是关于Python学习详细异常信息的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 各种自定义代码片段 - 有关详细信息,请参阅注释

代码学习PYTHON 异常处理

mvn命令异常:An error has occurred in Javadoc report generation: Unable to find javadoc command异常已解决(代码片段

mvn命令异常:An error has occurred in Javadoc report generation: Unable to find javadoc command异常已解决(代码片段

python 机器学习有用的代码片段

Android:GoogleMaps 标记详细信息片段