Remove boilerplate code from api error handling
If you look at the code for views in horizon dashboard, you will see a lot of this pattern repeating everywhere:
flavors = []
try:
flavors = api.nova.
except Exception:
This code would be repeated everywhere, where api.nova.
It would be nice to refactor that, for example using a decorator, like we did in Tuskar-UI: https:/
Then the default error message and value can be specified once, on the api method itself, and later overriden if needed.
The above code then turns into:
@handle_
def flavor_
...
api.
We can also use the decorator in-place explicitly, without having decorated the method:
handle_
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- Undefined
- Drafter:
- Radomir Dopieralski
- Direction:
- Needs approval
- Assignee:
- Radomir Dopieralski
- Definition:
- Obsolete
- Series goal:
- None
- Implementation:
- Unknown
- Milestone target:
- None
- Started by
- Completed by
- Rob Cresswell
Related branches
Related bugs
Sprints
Whiteboard
Gerrit topic: https:/
Addressed by: https:/
A decorated for handling errors
[peristeri 2014.11.11] The blueprint https:/