]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
API - handle any exceptions thrown during notice save. The API was
authorZach Copley <zach@status.net>
Thu, 18 Mar 2010 22:26:13 +0000 (15:26 -0700)
committerZach Copley <zach@status.net>
Thu, 18 Mar 2010 22:26:13 +0000 (15:26 -0700)
occasionally spitting out HTML, which is hard for clients to deal
with.

actions/apistatusesupdate.php

index bf367e1e181741e4d5626bd6332f0ae5432cc713..1956c85863d747173b4a15c8cc30e10f9caefe43 100644 (file)
@@ -244,11 +244,17 @@ class ApiStatusesUpdateAction extends ApiAuthAction
                 $options = array_merge($options, $locOptions);
             }
 
-            $this->notice =
-              Notice::saveNew($this->auth_user->id,
-                              $content,
-                              $this->source,
-                              $options);
+            try {
+                $this->notice = Notice::saveNew(
+                    $this->auth_user->id,
+                    $content,
+                    $this->source,
+                    $options
+                );
+            } catch (Exception $e) {
+                $this->clientError($e->getMessage());
+                return;
+            }
 
             if (isset($upload)) {
                 $upload->attachToNotice($this->notice);