Merge "Fix usage of NotFound exception"
This commit is contained in:
commit
9b863b6f60
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue