diff options
Diffstat (limited to 'qtip/api/controllers/common.py')
-rw-r--r-- | qtip/api/controllers/common.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/qtip/api/controllers/common.py b/qtip/api/controllers/common.py new file mode 100644 index 00000000..6cabbc7f --- /dev/null +++ b/qtip/api/controllers/common.py @@ -0,0 +1,19 @@ +import httplib + +import connexion + +from qtip.base import error + + +def get_one_exceptions(resource): + def _decorator(func): + def _execute(name): + try: + return func(name), httplib.OK + except error.NotFoundError: + return connexion.problem( + httplib.NOT_FOUND, + '{} Not Found'.format(resource), + 'Requested {} `{}` not found.'.format(resource, name)) + return _execute + return _decorator |