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 r
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: by_id(context, model, id) save_and_ reraise_ exception( ) as ctx:
ctx.log_ orig_exception = False
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. HealthMonitorNo tFound( monitor_ id=id)
ctx.log_ orig_exception = True
res = self._get_
except exc.NoResultFound:
with excutils.
if issubclass(model, Vip):
# if no match - log original exception
return r