summaryrefslogtreecommitdiffstats
path: root/controller/jsonhttperror.php
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-13 20:14:00 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-13 20:14:00 +0200
commitf82b818bdb852f63fdb4a431808f37902f4272ff (patch)
tree60e23d0b4b95a5f862661f3ad4fcc8cfa21f076f /controller/jsonhttperror.php
parentc9c7b457a09ed3f1899099bba60dad21ff6ad026 (diff)
break all the things!
Diffstat (limited to 'controller/jsonhttperror.php')
-rw-r--r--controller/jsonhttperror.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/controller/jsonhttperror.php b/controller/jsonhttperror.php
new file mode 100644
index 000000000..5948a8a63
--- /dev/null
+++ b/controller/jsonhttperror.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Alessandro Cosentino <cosenal@gmail.com>
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Alessandro Cosentino 2012
+ * @copyright Bernhard Posselt 2012, 2014
+ */
+
+namespace OCA\News\Controller;
+
+use \OCP\AppFramework\Http\JSONResponse;
+
+
+trait JSONHttpError {
+
+
+ /**
+ * @param \Excpetion $exception the message that is returned taken from the
+ * exception
+ * @param int the http error code
+ * @return \OCP\AppFramework\Http\JSONResponse
+ */
+ protected function error($exception, $code) {
+ return new JSONResponse(
+ array('message' => $exception->getMessage()),
+ $code
+ );
+ }
+
+
+} \ No newline at end of file