Skip to content

Commit

Permalink
Construct error message inside of error instead of outside
Browse files Browse the repository at this point in the history
  • Loading branch information
non-Jedi committed Oct 25, 2017
1 parent 10db977 commit 3982688
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions matrix_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ def _send(self, method, path, content=None, query_params={}, headers={},
verify=self.validate_cert
)
except requests.exceptions.RequestException as e:
raise MatrixHttpLibError(
"Something went wrong in {} requesting {}".format(method, endpoint), e
)
raise MatrixHttpLibError(e, method, endpoint)

if response.status_code == 429:
sleep(response.json()['retry_after_ms'] / 1000)
Expand Down
6 changes: 4 additions & 2 deletions matrix_client/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def __init__(self, code=0, content=""):
class MatrixHttpLibError(MatrixError):
"""The library used for http requests raised an exception."""

def __init__(self, msg, original_exception):
super(MatrixHttpLibError, self).__init__(msg + ": {}".format(original_exception))
def __init__(self, original_exception, method, endpoint):
super(MatrixHttpLibError, self).__init__(
"Something went wrong in {} requesting {}: {}".format(original_exception)
)
self.original_exception = original_exception

0 comments on commit 3982688

Please sign in to comment.