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
Fix proposed to branch: master /review. openstack. org/80222
Review: https:/