处理函数抛出异常的装饰器， ATT: on_exception必填
    :param on_exception: 遇到异常时函数返回什么内容

def no_exception(on_exception, logger=None):
    """
    处理函数抛出异常的装饰器， ATT: on_exception必填
    :param on_exception: 遇到异常时函数返回什么内容
    """

    def decorator(function):
        def wrapper(*args, **kwargs):
            try:
                result = function(*args, **kwargs)
            except Exception, e:
                if hasattr(logger, 'exception'):
                    logger.exception(e)
                else:
                    print traceback.format_exc()
                result = on_exception
            return result

        return wrapper

    return decorator