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