We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 0faa988e authored by Zach Copley's avatar Zach Copley

Fix for issue ID 2290: make sure errors are returned in the right

format, and use callback for errors when the request is JSONP
parent 4e8e77f6
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* @category API * @category API
* @package StatusNet * @package StatusNet
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @copyright 2009 StatusNet, Inc. * @copyright 2009-2010 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
*/ */
...@@ -131,7 +131,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction ...@@ -131,7 +131,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
try { try {
$this->setColors($design); $this->setColors($design);
} catch (WebColorException $e) { } catch (WebColorException $e) {
$this->clientError($e->getMessage()); $this->clientError($e->getMessage(), 400, $this->format);
return false; return false;
} }
...@@ -153,7 +153,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction ...@@ -153,7 +153,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
try { try {
$this->setColors($design); $this->setColors($design);
} catch (WebColorException $e) { } catch (WebColorException $e) {
$this->clientError($e->getMessage()); $this->clientError($e->getMessage(), 400, $this->format);
return false; return false;
} }
......
...@@ -88,15 +88,15 @@ class ApiMediaUploadAction extends ApiAuthAction ...@@ -88,15 +88,15 @@ class ApiMediaUploadAction extends ApiAuthAction
try { try {
$upload = MediaFile::fromUpload('media', $this->auth_user); $upload = MediaFile::fromUpload('media', $this->auth_user);
} catch (ClientException $ce) { } catch (Exception $e) {
$this->clientError($ce->getMessage()); $this->clientError($e->getMessage(), $e->getCode());
return; return;
} }
if (isset($upload)) { if (isset($upload)) {
$this->showResponse($upload); $this->showResponse($upload);
} else { } else {
$this->clientError('Upload failed.'); $this->clientError(_('Upload failed.'));
return; return;
} }
} }
......
...@@ -196,7 +196,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction ...@@ -196,7 +196,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction
if ($_SERVER['REQUEST_METHOD'] != 'POST') { if ($_SERVER['REQUEST_METHOD'] != 'POST') {
$this->clientError( $this->clientError(
_('This method requires a POST.'), _('This method requires a POST.'),
400, $this->format 400,
$this->format
); );
return; return;
} }
...@@ -217,7 +218,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction ...@@ -217,7 +218,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
if (empty($this->status)) { if (empty($this->status)) {
$this->clientError( $this->clientError(
'Client must provide a \'status\' parameter with a value.', _('Client must provide a \'status\' parameter with a value.'),
400, 400,
$this->format $this->format
); );
...@@ -291,8 +292,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction ...@@ -291,8 +292,8 @@ class ApiStatusesUpdateAction extends ApiAuthAction
try { try {
$upload = MediaFile::fromUpload('media', $this->auth_user); $upload = MediaFile::fromUpload('media', $this->auth_user);
} catch (ClientException $ce) { } catch (Exception $e) {
$this->clientError($ce->getMessage()); $this->clientError($e->getMessage(), $e->getCode(), $this->format);
return; return;
} }
...@@ -305,7 +306,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction ...@@ -305,7 +306,11 @@ class ApiStatusesUpdateAction extends ApiAuthAction
'Max notice size is %d chars, ' . 'Max notice size is %d chars, ' .
'including attachment URL.' 'including attachment URL.'
); );
$this->clientError(sprintf($msg, Notice::maxContent())); $this->clientError(
sprintf($msg, Notice::maxContent()),
400,
$this->format
);
} }
} }
...@@ -332,7 +337,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction ...@@ -332,7 +337,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
$options $options
); );
} catch (Exception $e) { } catch (Exception $e) {
$this->clientError($e->getMessage(), $e->getCode()); $this->clientError($e->getMessage(), $e->getCode(), $this->format);
return; return;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* @author Evan Prodromou <evan@status.net> * @author Evan Prodromou <evan@status.net>
* @author Jeffery To <jeffery.to@gmail.com> * @author Jeffery To <jeffery.to@gmail.com>
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @copyright 2009 StatusNet, Inc. * @copyright 2009-2010 StatusNet, Inc.
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
...@@ -138,7 +138,9 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction ...@@ -138,7 +138,9 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$this->raw($atom->getString()); $this->raw($atom->getString());
} catch (Atom10FeedException $e) { } catch (Atom10FeedException $e) {
$this->serverError( $this->serverError(
'Could not generate feed for group - ' . $e->getMessage() 'Could not generate feed for group - ' . $e->getMessage(),
400,
$this->format
); );
return; return;
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* @author Jeffery To <jeffery.to@gmail.com> * @author Jeffery To <jeffery.to@gmail.com>
* @author Toby Inkster <mail@tobyinkster.co.uk> * @author Toby Inkster <mail@tobyinkster.co.uk>
* @author Zach Copley <zach@status.net> * @author Zach Copley <zach@status.net>
* @copyright 2009 StatusNet, Inc. * @copyright 2009-2010 StatusNet, Inc.
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/ * @link http://status.net/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment