unify raise exception process
[releng.git] / utils / test / testapi / opnfv_testapi / common / raises.py
1 import httplib
2
3 from tornado import web
4
5
6 class Raiser(object):
7     code = httplib.OK
8
9     def __init__(self, reason):
10         raise web.HTTPError(self.code, reason)
11
12
13 class BadRequest(Raiser):
14     code = httplib.BAD_REQUEST
15
16
17 class Forbidden(Raiser):
18     code = httplib.FORBIDDEN
19
20
21 class NotFound(Raiser):
22     code = httplib.NOT_FOUND
23
24
25 class Unauthorized(Raiser):
26     code = httplib.UNAUTHORIZED
27
28
29 class CodeTBD(object):
30     def __init__(self, code, reason):
31         raise web.HTTPError(code, reason)