projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added --storage-classes argument to arv-put.
[arvados.git]
/
sdk
/
python
/
arvados
/
errors.py
diff --git
a/sdk/python/arvados/errors.py
b/sdk/python/arvados/errors.py
index ab4609f697cbec512f7b194efdc51bbcc9be4374..4fe1f76543a356f1c36aafea23efbc5895088c87 100644
(file)
--- a/
sdk/python/arvados/errors.py
+++ b/
sdk/python/arvados/errors.py
@@
-1,7
+1,10
@@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
# errors.py - Arvados-specific exceptions.
import json
# errors.py - Arvados-specific exceptions.
import json
-import requests
from apiclient import errors as apiclient_errors
from collections import OrderedDict
from apiclient import errors as apiclient_errors
from collections import OrderedDict
@@
-9,7
+12,7
@@
from collections import OrderedDict
class ApiError(apiclient_errors.HttpError):
def _get_reason(self):
try:
class ApiError(apiclient_errors.HttpError):
def _get_reason(self):
try:
- return '; '.join(json.loads(self.content)['errors'])
+ return '; '.join(json.loads(self.content
.decode('utf-8')
)['errors'])
except (KeyError, TypeError, ValueError):
return super(ApiError, self)._get_reason()
except (KeyError, TypeError, ValueError):
return super(ApiError, self)._get_reason()
@@
-30,12
+33,15
@@
class KeepRequestError(Exception):
These will be packed into an OrderedDict, available through the
request_errors() method.
These will be packed into an OrderedDict, available through the
request_errors() method.
+ :label:
+ A label indicating the type of value in the 'key' position of request_errors.
+
"""
self.label = label
self._request_errors = OrderedDict(request_errors)
if self._request_errors:
exc_reports = [self._format_error(*err_pair)
"""
self.label = label
self._request_errors = OrderedDict(request_errors)
if self._request_errors:
exc_reports = [self._format_error(*err_pair)
- for err_pair in self._request_errors.ite
rite
ms()]
+ for err_pair in self._request_errors.items()]
base_msg = "{}: {}".format(message, "; ".join(exc_reports))
else:
base_msg = message
base_msg = "{}: {}".format(message, "; ".join(exc_reports))
else:
base_msg = message
@@
-43,7
+49,7
@@
class KeepRequestError(Exception):
self.message = message
def _format_error(self, key, error):
self.message = message
def _format_error(self, key, error):
- if isinstance(error,
requests.Response
):
+ if isinstance(error,
HttpError
):
err_fmt = "{} {} responded with {e.status_code} {e.reason}"
else:
err_fmt = "{} {} raised {e.__class__.__name__} ({e})"
err_fmt = "{} {} responded with {e.status_code} {e.reason}"
else:
err_fmt = "{} {} raised {e.__class__.__name__} ({e})"
@@
-58,6
+64,12
@@
class KeepRequestError(Exception):
return self._request_errors
return self._request_errors
+class HttpError(Exception):
+ def __init__(self, status_code, reason):
+ self.status_code = status_code
+ self.reason = reason
+
+
class ArgumentError(Exception):
pass
class SyntaxError(Exception):
class ArgumentError(Exception):
pass
class SyntaxError(Exception):