diff options
author | Cheskel Twersky <twerskycheskel@gmail.com> | 2021-09-02 12:06:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-02 09:06:09 +0000 |
commit | d5cf4e0b1537eeafdb96ae831bbdffc5f1c6a94c (patch) | |
tree | 3d3fb318e9e11e81dea5659f742fb33f98a9682d | |
parent | bbc43858daee635faa5f232392985c1839219fca (diff) | |
download | google-api-python-client-d5cf4e0b1537eeafdb96ae831bbdffc5f1c6a94c.tar.gz |
fix: remove repeated calls to self._get_reason (#1513)
self._get_reason is being called in \_\_init\_\_ (https://github.com/googleapis/google-api-python-client/pull/1185) , so why not save it then?
also in the \_\_repr\_\_ function we got the reason by calling the _get_reason function right in the beginning, but was then called again.
-rw-r--r-- | googleapiclient/errors.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/googleapiclient/errors.py b/googleapiclient/errors.py index 332327ec0..385558c48 100644 --- a/googleapiclient/errors.py +++ b/googleapiclient/errors.py @@ -43,7 +43,7 @@ class HttpError(Error): self.content = content self.uri = uri self.error_details = "" - self._get_reason() + self.reason = self._get_reason() @property def status_code(self): @@ -75,25 +75,24 @@ class HttpError(Error): pass if reason is None: reason = "" - return reason + return reason.strip() def __repr__(self): - reason = self._get_reason() if self.error_details: return '<HttpError %s when requesting %s returned "%s". Details: "%s">' % ( self.resp.status, self.uri, - reason.strip(), + self.reason, self.error_details, ) elif self.uri: return '<HttpError %s when requesting %s returned "%s">' % ( self.resp.status, self.uri, - self._get_reason().strip(), + self.reason, ) else: - return '<HttpError %s "%s">' % (self.resp.status, self._get_reason()) + return '<HttpError %s "%s">' % (self.resp.status, self.reason) __str__ = __repr__ |