def getBacktrace(empty='Empty backtrace.'):
 try:
  info = sys.exc_info()
  trace = traceback.format_exception(*info)
  sys.exc_clear()
  if (trace[0] != 'None\n'):
   return ''.join(trace)
 except:
  return 'Error while trying to get backtrace'
 return empty

def getBacktrace ( empty = 'Empty backtrace.' ) : try : info = sys . exc_info ( ) trace = traceback . format_exception ( * info ) sys . exc_clear ( ) if ( trace [ 0 ] != 'None\n' ) : return '' . join ( trace ) except : return 'Error while trying to get backtrace' return empty
try to get backtrace as string .