From 9a62b7b18f6817fe9816104063d53d93555e2bfb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 21 Apr 2011 15:25:29 -0400 Subject: [PATCH] better error-handling when it's Ajax --- plugins/Bookmark/newbookmark.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/Bookmark/newbookmark.php b/plugins/Bookmark/newbookmark.php index 92e9bc81c5..d60d3d4670 100644 --- a/plugins/Bookmark/newbookmark.php +++ b/plugins/Bookmark/newbookmark.php @@ -75,6 +75,10 @@ class NewbookmarkAction extends Action { parent::prepare($argarray); + if ($this->boolean('ajax')) { + StatusNet::setApi(true); + } + $this->user = common_current_user(); if (empty($this->user)) { @@ -122,9 +126,6 @@ class NewbookmarkAction extends Action */ function newBookmark() { - if ($this->boolean('ajax')) { - StatusNet::setApi(true); - } try { if (empty($this->title)) { // TRANS: Client exception thrown when trying to create a new bookmark without a title. @@ -148,9 +149,13 @@ class NewbookmarkAction extends Action $options); } catch (ClientException $ce) { - $this->error = $ce->getMessage(); - $this->showPage(); - return; + if ($this->boolean('ajax')) { + throw $ce; + } else { + $this->error = $ce->getMessage(); + $this->showPage(); + return; + } } if ($this->boolean('ajax')) { -- 2.39.5