def wrap_exception(notifier=None, publisher_id=None, event_type=None,
                   level=None):
    # TODO(sandy): Find a way to import nova.notifier.api so we don't have
    # to pass it in as a parameter. Otherwise we get a cyclic import of
    # nova.notifier.api -> nova.utils -> nova.exception :(
    # TODO(johannes): Also, it would be nice to use
    # utils.save_and_reraise_exception() without an import loop
    def inner(f):
        def wrapped(*args, **kw):
            try:
                return f(*args, **kw)
            except Exception, e:
                # Save exception since it can be clobbered during processing
                # below before we can re-raise
                exc_info = sys.exc_info()

                if notifier:
                    payload = dict(args=args, exception=e)
                    payload.update(kw)

                    # Use a temp vars so we don't shadow
                    # our outer definitions.
                    temp_level = level
                    if not temp_level:
                        temp_level = notifier.ERROR

                    temp_type = event_type
                    if not temp_type:
                        # If f has multiple decorators, they must use
                        # functools.wraps to ensure the name is
                        # propagated.
                        temp_type = f.__name__

                    notifier.notify(publisher_id, temp_type, temp_level,
                                    payload)

                if (not isinstance(e, Error) and
                    not isinstance(e, NovaException)):
                    #exc_type, exc_value, exc_traceback = sys.exc_info()
                    LOG.exception(_('Uncaught exception'))
                    #logging.error(traceback.extract_stack(exc_traceback))
                    raise Error(str(e))

                # re-raise original exception since it may have been clobbered
                raise exc_info[0], exc_info[1], exc_info[2]

        return wraps(f)(wrapped)
    return inner
Get the line number from a frame object, allowing for optimization.
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/exception.py/wrap_exception--crossover with--dataset/ETHPy150Open cournape/Bento/bento/compat/inspect.py/getlineno