summaryrefslogtreecommitdiffstats
path: root/qtip/api/controllers/common.py
blob: 6cabbc7f36d61eb712c7d723554ff8b58a36d32a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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