summaryrefslogtreecommitdiffstats
path: root/controller/jsonhttperror.php
diff options
context:
space:
mode:
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