aboutsummaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'qtip/api/controllers/common.py')
-rw-r--r--qtip/api/controllers/common.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/qtip/api/controllers/common.py b/qtip/api/controllers/common.py
index eeae0fe..6ddab7a 100644
--- a/qtip/api/controllers/common.py
+++ b/qtip/api/controllers/common.py
@@ -14,15 +14,22 @@ import connexion
from qtip.base import error
-def get_one_exceptions(resource):
+def check_endpoint_for_error(resource, operation=None):
def _decorator(func):
- def _execute(name):
+ def _execute(name=None):
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))
+ '{} not found'.format(resource),
+ 'Requested {} `{}` not found.'
+ .format(resource.lower(), name))
+ except error.ToBeDoneError:
+ return connexion.problem(
+ httplib.NOT_IMPLEMENTED,
+ '{} handler not implemented'.format(operation),
+ 'Requested operation `{}` on {} not implemented.'
+ .format(operation.lower(), resource.lower()))
return _execute
return _decorator