diff options
Diffstat (limited to 'lib/Controller/JSONHttpErrorTrait.php')
-rw-r--r-- | lib/Controller/JSONHttpErrorTrait.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/Controller/JSONHttpErrorTrait.php b/lib/Controller/JSONHttpErrorTrait.php index 5c5d7a8cf..3defc47c1 100644 --- a/lib/Controller/JSONHttpErrorTrait.php +++ b/lib/Controller/JSONHttpErrorTrait.php @@ -30,13 +30,28 @@ trait JSONHttpErrorTrait * @param int $code * @return \OCP\AppFramework\Http\JSONResponse */ - public function errorResponseV2(\Exception $exception, $code) + public function errorResponseWithExceptionV2(\Exception $exception, $code) + { + return $this->errorResponseV2( + $exception->getMessage(), + $exception->getCode(), + $code + ); + } + + /** + * @param string $message + * @param int $code + * @param int $httpStatusCode + * @return \OCP\AppFramework\Http\JSONResponse + */ + public function errorResponseV2(string $message, int $code, int $httpStatusCode) { return new JSONResponse([ 'error' => [ - 'code' => $exception->getCode(), - 'message' => $exception->getMessage() + 'code' => $code, + 'message' => $message, ] - ], $code); + ], $httpStatusCode); } } |