#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
__title__ = '鲁棒性工具类'

@Time    : 2020/9/30 14:51
@Author  : zhengwangeng
@Software: PyCharm

# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
              ┏┓      ┏┓
            ┏┛┻━━━┛┻┓
            ┃      ☃      ┃
            ┃  ┳┛  ┗┳  ┃
            ┃      ┻      ┃
            ┗━┓      ┏━┛
                ┃      ┗━━━┓
                ┃  神兽保佑    ┣┓
                ┃　永无BUG！   ┏┛
                ┗┓┓┏━┳┓┏┛
                  ┃┫┫  ┃┫┫
                  ┗┻┛  ┗┻┛
"""

import sys

import traceback


# 异常处理装饰器
def catch_exception(actual_do):
    def add_robust(*args, **keyargs):
        try:
            return actual_do(*args, **keyargs)
        except Exception as err:
            # print('Error execute: %s' % actual_do.__name__)
            info = sys.exc_info()[2].tb_frame.f_back
            temp = "exception:filename:{}\tlines:{}\tfuncation:{}\terror:{}"
            # print(temp.format(info.f_code.co_filename, info.f_lineno, actual_do.__name__, repr(err)))
            traceback.print_exc()

    return add_robust
