Merge "Fix usage of NotFound exception"

This commit is contained in:
Zuul 2019-08-22 20:57:23 +00:00 committed by Gerrit Code Review
commit 9b863b6f60
2 changed files with 5 additions and 2 deletions

View File

@ -361,7 +361,7 @@ class BaseAPI(object):
num_bulk = len(bulk_list)
if num_bulk == 0:
msg = _("none found")
raise exceptions.NotFound(msg)
raise exceptions.NotFound(404, msg)
elif num_bulk > 1:
msg = _("many found")
raise RuntimeError(msg)
@ -388,7 +388,7 @@ class BaseAPI(object):
def raise_not_found():
msg = _("%s not found") % value
raise exceptions.NotFound(msg)
raise exceptions.NotFound(404, msg)
try:
ret = self._request(

View File

@ -55,6 +55,9 @@ class ClientException(Exception):
"""The base exception class for all exceptions this library raises."""
def __init__(self, code, message=None, details=None):
if not isinstance(code, int) and message is None:
message = code
code = self.http_status
self.code = code
self.message = message or self.__class__.message
self.details = details