/**
  * Log error message and return a response which can be displayed to the user
  *
  * @param \OCP\AppFramework\Controller $controller
  * @param string $methodName
  * @param \Exception $exception
  * @return JSONResponse
  */
 public function afterException($controller, $methodName, \Exception $exception)
 {
     $this->logger->error($exception->getMessage(), ['app' => $this->appName]);
     if ($exception instanceof HintException) {
         $message = $exception->getHint();
     } else {
         $message = $exception->getMessage();
     }
     return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
 }