From f82b818bdb852f63fdb4a431808f37902f4272ff Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Tue, 13 May 2014 20:14:00 +0200 Subject: break all the things! --- controller/jsonhttperror.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 controller/jsonhttperror.php (limited to 'controller/jsonhttperror.php') 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 @@ + + * @author Bernhard Posselt + * @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 -- cgit v1.2.3