Return a nice text document describing the traceback.
(self, etype, evalue, etb, tb_offset=None,
number_of_lines_of_context=5)
| 1186 | return None |
| 1187 | |
| 1188 | def structured_traceback(self, etype, evalue, etb, tb_offset=None, |
| 1189 | number_of_lines_of_context=5): |
| 1190 | """Return a nice text document describing the traceback.""" |
| 1191 | |
| 1192 | formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, |
| 1193 | tb_offset) |
| 1194 | |
| 1195 | colors = self.Colors # just a shorthand + quicker name lookup |
| 1196 | colorsnormal = colors.Normal # used a lot |
| 1197 | head = '%s%s%s' % (colors.topline, '-' * min(75, get_terminal_size()[0]), colorsnormal) |
| 1198 | structured_traceback_parts = [head] |
| 1199 | chained_exceptions_tb_offset = 0 |
| 1200 | lines_of_context = 3 |
| 1201 | formatted_exceptions = formatted_exception |
| 1202 | exception = self.get_parts_of_chained_exception(evalue) |
| 1203 | if exception: |
| 1204 | formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__) |
| 1205 | etype, evalue, etb = exception |
| 1206 | else: |
| 1207 | evalue = None |
| 1208 | chained_exc_ids = set() |
| 1209 | while evalue: |
| 1210 | formatted_exceptions += self.format_exception_as_a_whole(etype, evalue, etb, lines_of_context, |
| 1211 | chained_exceptions_tb_offset) |
| 1212 | exception = self.get_parts_of_chained_exception(evalue) |
| 1213 | |
| 1214 | if exception and not id(exception[1]) in chained_exc_ids: |
| 1215 | chained_exc_ids.add(id(exception[1])) # trace exception to avoid infinite 'cause' loop |
| 1216 | formatted_exceptions += self.prepare_chained_exception_message(evalue.__cause__) |
| 1217 | etype, evalue, etb = exception |
| 1218 | else: |
| 1219 | evalue = None |
| 1220 | |
| 1221 | # we want to see exceptions in a reversed order: |
| 1222 | # the first exception should be on top |
| 1223 | for formatted_exception in reversed(formatted_exceptions): |
| 1224 | structured_traceback_parts += formatted_exception |
| 1225 | |
| 1226 | return structured_traceback_parts |
| 1227 | |
| 1228 | def debugger(self, force=False): |
| 1229 | """Call up the pdb debugger if desired, always clean up the tb |
nothing calls this directly
no test coverage detected