##// END OF EJS Templates
i1673 use __cause__ first in chained exceptions
Justyna Ilczuk -
Show More
@@ -967,17 +967,17 b' class VerboseTB(TBTools):'
967 info('\nUnfortunately, your original traceback can not be constructed.\n')
967 info('\nUnfortunately, your original traceback can not be constructed.\n')
968 return None
968 return None
969
969
970 def get_exception_from_context(self, evalue):
970 def get_parts_of_chained_exception(self, evalue):
971 if hasattr(evalue, '__context__'):
971 def get_chained_exception(exception_value):
972 context = evalue.__context__
972 cause = getattr(exception_value, '__cause__', None)
973 if not context:
973 if cause:
974 return None
974 return cause
975 else:
975 return getattr(exception_value, '__context__', None)
976 exception_traceback = context.__traceback__
976
977 exception_type = context.__class__
977 chained_evalue = get_chained_exception(evalue)
978 return exception_type, context, exception_traceback
978
979 else:
979 if chained_evalue:
980 return None
980 return chained_evalue.__class__, chained_evalue, chained_evalue.__traceback__
981
981
982 def structured_traceback(self, etype, evalue, etb, tb_offset=None,
982 def structured_traceback(self, etype, evalue, etb, tb_offset=None,
983 number_of_lines_of_context=5):
983 number_of_lines_of_context=5):
@@ -994,7 +994,7 b' class VerboseTB(TBTools):'
994 chained_exceptions_tb_offset = 0
994 chained_exceptions_tb_offset = 0
995 lines_of_context = 3
995 lines_of_context = 3
996 formatted_exceptions = formatted_exception
996 formatted_exceptions = formatted_exception
997 exception = self.get_exception_from_context(evalue)
997 exception = self.get_parts_of_chained_exception(evalue)
998 if exception:
998 if exception:
999 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
999 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
1000 etype, evalue, etb = exception
1000 etype, evalue, etb = exception
@@ -1003,7 +1003,8 b' class VerboseTB(TBTools):'
1003 while evalue:
1003 while evalue:
1004 formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
1004 formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context,
1005 chained_exceptions_tb_offset)
1005 chained_exceptions_tb_offset)
1006 exception = self.get_exception_from_context(evalue)
1006 exception = self.get_parts_of_chained_exception(evalue)
1007
1007 if exception:
1008 if exception:
1008 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
1009 formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__)
1009 etype, evalue, etb = exception
1010 etype, evalue, etb = exception
General Comments 0
You need to be logged in to leave comments. Login now