File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -379,11 +379,14 @@ def test_chained_exceptions_stacktrace(self):
379
379
class CustomException (Exception ):
380
380
if PY2 :
381
381
def __str__ (self ):
382
- out = Exception .__str__ (self )
383
- if hasattr (self , '__cause__' ) and self .__cause__ and hasattr (self .__cause__ , '__traceback__' ) and self .__cause__ .__traceback__ :
384
- out += '\n \n The above exception was the direct cause of the following exception:\n \n '
385
- out += '' .join (traceback .format_tb (self .__cause__ .__traceback__ ) + ['{}: {}' .format (self .__cause__ .__class__ .__name__ , self .__cause__ .message )])
386
- return out
382
+ try :
383
+ out = Exception .__str__ (self )
384
+ if hasattr (self , '__cause__' ) and self .__cause__ and hasattr (self .__cause__ , '__traceback__' ) and self .__cause__ .__traceback__ :
385
+ out += '\n \n The above exception was the direct cause of the following exception:\n \n '
386
+ out += '' .join (traceback .format_tb (self .__cause__ .__traceback__ ) + ['{}: {}' .format (self .__cause__ .__class__ .__name__ , self .__cause__ )])
387
+ return out
388
+ except Exception as e :
389
+ print (e )
387
390
else :
388
391
pass
389
392
You can’t perform that action at this time.
0 commit comments