]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/command.php
newmessage (and Message class) fixed for FormAction
[quix0rs-gnu-social.git] / lib / command.php
index ae97b9facd31c3dd8801002d4901735a883940f2..e93b7fbfee62bb2237b9a69fdb7fb8e0cf8816dd 100644 (file)
@@ -632,15 +632,15 @@ class MessageCommand extends Command
             $channel->error($this->user, _('Do not send a message to yourself; just say it to yourself quietly instead.'));
             return;
         }
-        $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
-        if ($message) {
+        try {
+            $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
             $message->notify();
             // TRANS: Message given have sent a direct message to another user.
             // TRANS: %s is the name of the other user.
             $channel->output($this->user, sprintf(_('Direct message to %s sent.'), $this->other));
-        } else {
+        } catch (Exception $e) {
             // TRANS: Error text shown sending a direct message fails with an unknown reason.
-            $channel->error($this->user, _('Error sending direct message.'));
+            $channel->error($this->user, $e->getMessage());
         }
     }
 }