def exception_to_dict(fault, message=None):
 code = 500
 if hasattr(fault, 'kwargs'):
  code = fault.kwargs.get('code', 500)
 try:
  if (not message):
   message = fault.format_message()
 except Exception:
  try:
   message = six.text_type(fault)
  except Exception:
   message = None
 if (not message):
  message = fault.__class__.__name__
 u_message = utils.safe_truncate(message, 255)
 fault_dict = dict(exception=fault)
 fault_dict['message'] = u_message
 fault_dict['code'] = code
 return fault_dict

def exception_to_dict ( fault , message = None ) : code = 500 if hasattr ( fault , 'kwargs' ) : code = fault . kwargs . get ( 'code' , 500 ) try : if ( not message ) : message = fault . format_message ( ) except Exception : try : message = six . text_type ( fault ) except Exception : message = None if ( not message ) : message = fault . __class__ . __name__ u_message = utils . safe_truncate ( message , 255 ) fault_dict = dict ( exception = fault ) fault_dict [ 'message' ] = u_message fault_dict [ 'code' ] = code return fault_dict
converts exceptions to a dict for use in notifications .