X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c691e44f9183176581dd8da6417af16772baf510..7ab494e42b35b3769a326a16b7e90f1d20147ced:/sdk/python/arvados/errors.py diff --git a/sdk/python/arvados/errors.py b/sdk/python/arvados/errors.py index ab4609f697..bfd471ba52 100644 --- a/sdk/python/arvados/errors.py +++ b/sdk/python/arvados/errors.py @@ -1,7 +1,6 @@ # errors.py - Arvados-specific exceptions. import json -import requests from apiclient import errors as apiclient_errors from collections import OrderedDict @@ -30,6 +29,9 @@ class KeepRequestError(Exception): 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) @@ -43,7 +45,7 @@ class KeepRequestError(Exception): 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})" @@ -58,6 +60,12 @@ class KeepRequestError(Exception): 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):