? overlay_subtabs_invisible.png
Index: privatemsg.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.pages.inc,v
retrieving revision 1.1.2.11
diff -u -p -r1.1.2.11 privatemsg.pages.inc
--- privatemsg.pages.inc	7 Jul 2010 09:55:15 -0000	1.1.2.11
+++ privatemsg.pages.inc	8 Jul 2010 09:04:09 -0000
@@ -457,18 +457,28 @@ function privatemsg_new_preview($form, &
  * Submit callback for the privatemsg_new form.
  */
 function privatemsg_new_submit($form, &$form_state) {
-  $status = _privatemsg_send($form_state['validate_built_message']);
+  $message = $form_state['validate_built_message'];
+
   // Format each recipient.
   $recipient_names = array();
-  foreach ($form_state['validate_built_message']->recipients as $recipient) {
+  foreach ($message->recipients as $recipient) {
     $recipient_names[] = privatemsg_recipient_format($recipient);
   }
-  if ($status !== FALSE )  {
-    _privatemsg_handle_recipients($status->mid, $status->recipients);
+  field_attach_submit('privatemsg_message', $message, $form, $form_state);
+  try {
+    $message = _privatemsg_send($message);
+    _privatemsg_handle_recipients($message->mid, $message->recipients);
     drupal_set_message(t('A message has been sent to !recipients.', array('!recipients' => implode(', ', $recipient_names))));
   }
-  else {
-    drupal_set_message(t('An attempt to send a message <em>may have failed</em> when sending to !recipients.', array('!recipients' => implode(', ', $recipient_names))), 'error');
+  catch (Exception $e) {
+    if (error_displayable()) {
+      require_once DRUPAL_ROOT . '/includes/errors.inc';
+      $variables = _drupal_decode_exception($e);
+      drupal_set_message(t('Failed to send a message to !recipients. %type: %message in %function (line %line of %file).', array('!recipients' => implode(', ', $recipient_names)) + $variables), 'error');
+    }
+    else {
+      drupal_set_message(t('Failed to send a message to !recipients. Contact your site administrator.', array('!recipients' => implode(', ', $recipient_names))), 'error');
+    }
   }
 }
 
