diff options
author | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-03-31 01:42:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-03-31 01:42:44 +0000 |
commit | 8eb68cff96445dc53ee1c232b565aa4a61d0a526 (patch) | |
tree | 18706484d2ae582399724306ce65f5594b7363f7 /utils/test/testapi/opnfv_testapi/common/raises.py | |
parent | 85eba2eafa62f00eb3c28bb9968e89bcaba5e73e (diff) | |
parent | b9e0948256af817e63f901ec5277d3ef9fe36fdd (diff) |
Merge "unify raise exception process"
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/common/raises.py')
-rw-r--r-- | utils/test/testapi/opnfv_testapi/common/raises.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/utils/test/testapi/opnfv_testapi/common/raises.py b/utils/test/testapi/opnfv_testapi/common/raises.py new file mode 100644 index 000000000..ed3a84ee0 --- /dev/null +++ b/utils/test/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) |