Fixed incorrect filed "status_code" in exception

Previously, both BadRequest and NotFound exception contains
"status_code" attribution, which should be changed to "status" as
defined in base ValenceError class.
And assign fake request_id by default instead of None.

Change-Id: Icde52f98b4be2f48e9854b260aab4158b5e3a636
Closes-Bug: #1661136
This commit is contained in:
Lin Yang 2017-02-01 18:08:15 -08:00 committed by Andy Yan
parent d5d59f981d
commit 9fe21347cf

View File

@ -88,21 +88,22 @@ class RedfishException(ValenceError):
class NotFound(ValenceError):
def __init__(self, detail='resource not found', request_id=None):
def __init__(self, detail='resource not found',
request_id=FAKE_REQUEST_ID):
self.request_id = request_id
self.status_code = http_client.NOT_FOUND
self.code = http_client.NOT_FOUND
self.title = "resource not found"
self.status = http_client.NOT_FOUND
self.code = "NotFound"
self.title = "Resource NOT Found"
self.detail = detail
class BadRequest(ValenceError):
def __init__(self, detail='bad request', request_id=None):
def __init__(self, detail='bad request', request_id=FAKE_REQUEST_ID):
self.request_id = request_id
self.status_code = http_client.BAD_REQUEST
self.code = http_client.BAD_REQUEST
self.title = "bad request"
self.status = http_client.BAD_REQUEST
self.code = "BadRequest"
self.title = "Malformed or Missing Payload in Request"
self.detail = detail