-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
I was wondering if it be ok to include the full response object in the exception along with the args currently there? The response has the headers, and request, which can make logging failures easier. It also might be nice to include some attributes on the exception.
class StatusCodeError(TestRailAPIError):
def __init__(self, *args, **kwargs):
super().__init__(*args)
self.status_code = args[0]
self.reason = args[1]
self.url = args[2]
self.content = args[3]
self.response = kwargs.get('response')
existing args access still works, but you'd have attributes to hand onto.
>>> e = StatusCodeError(500, "bad", "url", "content", response={'a':1})
>>> e.args[0]
500
>>> e.status_code
500
>>> e.response
{'a': 1}
>>> raise e
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StatusCodeError: (500, 'bad', 'url', 'content')
Metadata
Metadata
Assignees
Labels
No labels