def serialize_remote_exception(failure_info, log_failure=True):
 tb = traceback.format_exception(*failure_info)
 failure = failure_info[1]
 if log_failure:
  LOG.error(_('Returning exception %s to caller'), six.text_type(failure))
  LOG.error(tb)
 kwargs = {}
 if hasattr(failure, 'kwargs'):
  kwargs = failure.kwargs
 cls_name = str(failure.__class__.__name__)
 mod_name = str(failure.__class__.__module__)
 if (cls_name.endswith(_REMOTE_POSTFIX) and mod_name.endswith(_REMOTE_POSTFIX)):
  cls_name = cls_name[:(- len(_REMOTE_POSTFIX))]
  mod_name = mod_name[:(- len(_REMOTE_POSTFIX))]
 data = {'class': cls_name, 'module': mod_name, 'message': six.text_type(failure), 'tb': tb, 'args': failure.args, 'kwargs': kwargs}
 json_data = jsonutils.dumps(data)
 return json_data

def serialize_remote_exception ( failure_info , log_failure = True ) : tb = traceback . format_exception ( * failure_info ) failure = failure_info [ 1 ] if log_failure : LOG . error ( _ ( 'Returning exception %s to caller' ) , six . text_type ( failure ) ) LOG . error ( tb ) kwargs = { } if hasattr ( failure , 'kwargs' ) : kwargs = failure . kwargs cls_name = str ( failure . __class__ . __name__ ) mod_name = str ( failure . __class__ . __module__ ) if ( cls_name . endswith ( _REMOTE_POSTFIX ) and mod_name . endswith ( _REMOTE_POSTFIX ) ) : cls_name = cls_name [ : ( - len ( _REMOTE_POSTFIX ) ) ] mod_name = mod_name [ : ( - len ( _REMOTE_POSTFIX ) ) ] data = { 'class' : cls_name , 'module' : mod_name , 'message' : six . text_type ( failure ) , 'tb' : tb , 'args' : failure . args , 'kwargs' : kwargs } json_data = jsonutils . dumps ( data ) return json_data
prepares exception data to be sent over rpc .