#NEWLINE# def serialize_remote_exception( failure_info , log_failure = True ) : #NEWLINE# #INDENT# 'Prepares exception data to be sent over rpc.\n\n    Failure_info should be a sys.exc_info() tuple.\n\n    ' #NEWLINE# tb = traceback . format_exception ( * failure_info ) #NEWLINE# failure = failure_info [ 1 ] #NEWLINE# if log_failure : #NEWLINE# #INDENT# LOG . error ( _ ( 'Returning exception %s to caller' ) , six . text_type ( failure ) ) #NEWLINE# LOG . error ( tb ) #NEWLINE# #UNINDENT# kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if hasattr ( failure , 'kwargs' ) : #NEWLINE# #INDENT# kwargs = failure . kwargs #NEWLINE# #UNINDENT# data = { #NEWLINE# #INDENT# 'class' : str ( failure . __class__ . __name__ ) , #NEWLINE# 'module' : str ( failure . __class__ . __module__ ) , #NEWLINE# 'message' : six . text_type ( failure ) , #NEWLINE# 'tb' : tb , #NEWLINE# 'args' : failure . args , #NEWLINE# 'kwargs' : kwargs , #NEWLINE# #UNINDENT# } #NEWLINE# json_data = jsonutils . dumps ( data ) #NEWLINE# return json_data