summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/common/raises.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-30 15:33:19 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-30 15:36:50 +0800
commit7c0915d9e6a9c81b4df6cd0ddda21287137e0088 (patch)
treeadef655d47005e278a55682ccc98eaf2c1c15a2b /testapi/opnfv_testapi/common/raises.py
parent87393f4eba3b68f9598c02dcbe1f06f2afdd400c (diff)
unify raise exception process
Change-Id: I109ef9550a57e218b6f5c9196812b33133d34134 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/common/raises.py')
-rw-r--r--testapi/opnfv_testapi/common/raises.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/common/raises.py b/testapi/opnfv_testapi/common/raises.py
new file mode 100644
index 0000000..ed3a84e
--- /dev/null
+++ b/testapi/opnfv_testapi/common/raises.py
@@ -0,0 +1,31 @@
+import httplib
+
+from tornado import web
+
+
+class Raiser(object):
+ code = httplib.OK
+
+ def __init__(self, reason):
+ raise web.HTTPError(self.code, reason)
+
+
+class BadRequest(Raiser):
+ code = httplib.BAD_REQUEST
+
+
+class Forbidden(Raiser):
+ code = httplib.FORBIDDEN
+
+
+class NotFound(Raiser):
+ code = httplib.NOT_FOUND
+
+
+class Unauthorized(Raiser):
+ code = httplib.UNAUTHORIZED
+
+
+class CodeTBD(object):
+ def __init__(self, code, reason):
+ raise web.HTTPError(code, reason)