@@ -14,10 +14,10 @@ def __init__(self, metadata, response):
1414 self .response = response
1515 self .tag = metadata ['tags' ][0 ]
1616 self .operation = metadata ['operation' ]
17- self .status = self .response .status_code if self .response else None
18- self .reason = self .response .reason if self .response else None
17+ self .status = self .response .status_code if self .response . status_code else None
18+ self .reason = self .response .reason if self .response . reason else None
1919 try :
20- self .message = self .response .json () if self .response else None
20+ self .message = self .response .json () if self .response . json () else None
2121 except ValueError :
2222 self .message = self .response .text [:100 ]
2323 super (APIError , self ).__init__ (f'{ self .tag } , { self .operation } - { self .status } { self .reason } , { self .message } ' )
@@ -31,9 +31,12 @@ def __init__(self, metadata, response, message):
3131 self .response = response
3232 self .tag = metadata ['tags' ][0 ]
3333 self .operation = metadata ['operation' ]
34- self .status = self .response .status if self .response else None
35- self .reason = self .response .reason if self .response else None
36- self .message = message [:100 ]
34+ self .status = self .response .status if self .response .status else None
35+ self .reason = self .response .reason if self .response .reason else None
36+ try :
37+ self .message = self .response .json () if self .response .json () else None
38+ except ValueError :
39+ self .message = self .response .text [:100 ]
3740 super ().__init__ (
3841 f'{ self .tag } , { self .operation } - { self .status } { self .reason } , { self .message } '
3942 )
0 commit comments