Every line of 'python exception get message' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
310 def collect_exception_python2(): 311 """ 312 Collect exception from exception sys.exc_info. 313 :return: traceback data 314 """ 315 316 traceback_data = six.StringIO() 317 traceback.print_exception(*sys.exc_info(), file=traceback_data) 318 return traceback_data.getvalue()
299 def GetErrorDetails(): 300 """Returns a string representation of type and message of an exception.""" 301 return repr(sys.exc_info()[1])
30 def simple_exception(type, value, traceback): 31 sys.stderr.write("[!] Error!", value, "\n") 32 sys.exit(1)
331 def _extract_msg_from_last_exception(): 332 ''' Extract a useful error message from the last thrown exception ''' 333 last_exc_type, last_error, last_traceback = sys.exc_info() 334 if isinstance(last_error, exceptions.DXAPIError): 335 # Using the same code path as below would not 336 # produce a useful message when the error contains a 337 # 'details' hash (which would have a last line of 338 # '}') 339 return last_error.error_message() 340 else: 341 return traceback.format_exc().splitlines()[-1].strip()
106 def exceptionInfo(): 107 (exceptionType, exception, trace) = sys.exc_info() 108 etb = traceback.extract_tb(trace) 109 exceptionType = str(exceptionType.__name__) + ": " + str(exception) 110 exceptInfo = "" 111 for (module, line, function, location) in etb: 112 exceptInfo += " File " + str(module) + ", line " + str(line) + ", in " + str(function) + "\n> " + str(location) + "\n" 113 return ( __getCallContext( withLineNumber = True ), "Exception traceback:\n" + exceptInfo + exceptionType)
23 def exception_string(): 24 """called to extract useful information from an exception""" 25 exc = sys.exc_info() 26 exc_type = _typename(exc[0]) 27 exc_message = str(exc[1]) 28 exc_contents = "".join(traceback.format_exception(*sys.exc_info())) 29 return "[%s]\n %s" % (exc_type, exc_contents)
36 def get_message(exception): 37 message = None 38 39 if hasattr(exception, 'message'): 40 message = exception.message 41 elif hasattr(exception, '__str__'): 42 message = e.__str__() 43 else: 44 message = "Something went wrong while syncing" 45 return message