diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2020-09-28 21:07:24 +0200 |
---|---|---|
committer | Benjamin Brahmer <info@b-brahmer.de> | 2020-09-29 13:02:03 +0200 |
commit | bc01761221384c0bbac0297d38e85bcaa6286a9a (patch) | |
tree | bea5acc2db33186982ba94a4270c9eb277c8f0b3 /lib/Controller/JSONHttpErrorTrait.php | |
parent | d00d1ab2a28f428223e52b17052c072c64784016 (diff) |
Fix repair step and test it
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Controller/JSONHttpErrorTrait.php')
-rw-r--r-- | lib/Controller/JSONHttpErrorTrait.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/Controller/JSONHttpErrorTrait.php b/lib/Controller/JSONHttpErrorTrait.php new file mode 100644 index 000000000..785f3f02a --- /dev/null +++ b/lib/Controller/JSONHttpErrorTrait.php @@ -0,0 +1,27 @@ +<?php +/** + * Nextcloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ + +namespace OCA\News\Controller; + +use \OCP\AppFramework\Http\JSONResponse; + +trait JSONHttpErrorTrait +{ + /** + * @param \Exception $exception The exception to report + * @param int $code The http error code + * @return JSONResponse + */ + public function error(\Exception $exception, $code) + { + return new JSONResponse(['message' => $exception->getMessage()], $code); + } +} |