code: def print_exception_formatted(type, value, tb):
      
  
      tbtext = ''.join(traceback.format_exception(type, value, tb))
      lexer = get_lexer_by_name('pytb', stripall=True)
      formatter = TerminalFormatter()
      sys.stderr.write(highlight(tbtext, lexer, formatter))
docs: A custom hook for printing tracebacks with colours.