Set default error message for for forbidden
The issue is that some error dialog shows "the JSON object must be str, bytes or bytearray, not NoneType" when non admin user tries to modify configuration. Functional-wise it is expected behavior to reject configure operation because of forbidden. But this message is not proper for users. This happens when it extracts the error message from api, it is a case to be empty. The fix is check empty message and show the default message if it is empty. Closes-bug: 2037320 Test Plan: PASS: Confirm error message dialog contains proper text in detail. Change-Id: I980df3356b60a59b19ec8b552f848e63dec3b621 Signed-off-by: Takamasa Takenaka <takamasa.takenaka@windriver.com>
This commit is contained in:
parent
63ffee43a0
commit
56a6555315
|
@ -408,10 +408,12 @@ class HTTPClient(httplib2.Http):
|
|||
if status_code == 401:
|
||||
raise exceptions.HTTPUnauthorized(body)
|
||||
elif status_code == 403:
|
||||
error_json = self._extract_error_json(body_str)
|
||||
reason = error_json.get('faultstring')
|
||||
if reason is None:
|
||||
reason = error_json.get('description')
|
||||
reason = "Not allowed/Proper role is needed"
|
||||
if body_str is not None:
|
||||
error_json = self._extract_error_json(body_str)
|
||||
reason = error_json.get('faultstring')
|
||||
if reason is None:
|
||||
reason = error_json.get('description')
|
||||
raise exceptions.Forbidden(reason)
|
||||
elif 400 <= status_code < 600:
|
||||
_logger.warn("Request returned failure status: %s", status_code) # pylint: disable=deprecated-method
|
||||
|
|
Loading…
Reference in New Issue