save_and_reraise_exception: sometimes logging original exception is undesired

Bug #1291850 reported by Oleg Bondarev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo-incubator
Fix Released
Undecided
Oleg Bondarev

Bug Description

In some cases the whole purpose of exception handler is to reraise proper type of exception - for such cases there is often no need to log original exception being dropped as described here: https://bugs.launchpad.net/neutron/+bug/1288188

The proposal would be to add 'log_orig_exception' flag simular to 'reraise' to let user omit logging original exception. Example of usage:

        try:
            res = self._get_by_id(context, model, id)
        except exc.NoResultFound:
            with excutils.save_and_reraise_exception() as ctx:
                ctx.log_orig_exception = False
                if issubclass(model, Vip):
                    raise loadbalancer.VipNotFound(vip_id=id)
                elif issubclass(model, Pool):
                    raise loadbalancer.PoolNotFound(pool_id=id)
                elif issubclass(model, Member):
                    raise loadbalancer.MemberNotFound(member_id=id)
                elif issubclass(model, HealthMonitor):
                    raise loadbalancer.HealthMonitorNotFound(monitor_id=id)
                # if no match - log original exception
                ctx.log_orig_exception = True
        return res

Changed in oslo:
assignee: nobody → Oleg Bondarev (obondarev)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

Fix proposed to branch: master
Review: https://review.openstack.org/80222

Changed in oslo:
status: New → In Progress
Changed in oslo:
assignee: Oleg Bondarev (obondarev) → Ben Nemec (bnemec)
Ben Nemec (bnemec)
Changed in oslo:
assignee: Ben Nemec (bnemec) → Oleg Bondarev (obondarev)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/80222
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=33a2cee6a690ecfdb2cecfe8f01b0b1dacb5bd17
Submitter: Jenkins
Branch: master

commit 33a2cee6a690ecfdb2cecfe8f01b0b1dacb5bd17
Author: Oleg Bondarev <email address hidden>
Date: Thu Mar 13 13:32:09 2014 +0400

    save_and_reraise_exception: make logging respect the reraise parameter

    Do not log original exception if reraise is set to False

    Closes-Bug: #1291850
    Related-Bug: #1288188

    Change-Id: Icd5fcba25c2cd549cee70353a7a62d83bfe1255b

Changed in oslo:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in oslo:
milestone: none → icehouse-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in oslo:
milestone: icehouse-rc1 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.