Make raise/re-raise of exceptions in the code consistent

Registered by Rohit Karajgi

Re-raising exceptions across the code is somewhat skewed. At some places an
exception is handled and re-raised, at other places a plain raise statement is used and the
correct exception context may not be clear from the code.

Such statements should be identified and refactored to use the right contextual exception
object during a re-raise and supplement with a LOG message if needed.

Example from current trunk:
1.
        except Exception:
            try:
                with excutils.save_and_reraise_exception():
                    LOG.exception(_('Failed to get nw_info'),
                                  instance=instance_ref)
            except Exception:
                if ignore_missing_network_data:
                    return
                raise # Specify the exception object that should be re-raised in this context

https://github.com/openstack/nova/blob/master/nova/notifications.py#L237

2. except OSError as e:
        if e.errno == errno.ENOENT:
            return
        else:
            raise # will be clearer if the caught object 'e' is passed as an expression here

https://github.com/openstack/nova/blob/master/nova/utils.py#L453

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
Rohit Karajgi
Direction:
Needs approval
Assignee:
None
Definition:
Obsolete
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Russell Bryant

Related branches

Sprints

Whiteboard

Suggesting that we do "raise e" instead of just "raise" changes what's happening. That's not what we want in these cases. --russellb

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.