mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 03:11:09 +00:00
Export headers in GithubException (#1887)
Since the headers that led to an exception are also useful, firstly pass them into the constructor, and then export them in a property. Test one specific use case to make sure of coverage. Fixes #1814
This commit is contained in:
@@ -38,11 +38,12 @@ class GithubException(Exception):
|
||||
Some other types of exceptions might be raised by underlying libraries, for example for network-related issues.
|
||||
"""
|
||||
|
||||
def __init__(self, status, data):
|
||||
def __init__(self, status, data, headers):
|
||||
super().__init__()
|
||||
self.__status = status
|
||||
self.__data = data
|
||||
self.args = [status, data]
|
||||
self.__headers = headers
|
||||
self.args = [status, data, headers]
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
@@ -58,6 +59,13 @@ class GithubException(Exception):
|
||||
"""
|
||||
return self.__data
|
||||
|
||||
@property
|
||||
def headers(self):
|
||||
"""
|
||||
The headers returned by the Github API
|
||||
"""
|
||||
return self.__headers
|
||||
|
||||
def __str__(self):
|
||||
return "{status} {data}".format(status=self.status, data=json.dumps(self.data))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user