diff --git a/src/Mouf/Mvc/Splash/Controllers/Http500HandlerInterface.php b/src/Mouf/Mvc/Splash/Controllers/Http500HandlerInterface.php index 89d71bd..89d4721 100644 --- a/src/Mouf/Mvc/Splash/Controllers/Http500HandlerInterface.php +++ b/src/Mouf/Mvc/Splash/Controllers/Http500HandlerInterface.php @@ -1,6 +1,7 @@ exception = $exception; + + $acceptType = $request->getHeader('Accept'); + if (is_array($acceptType) && count($acceptType) > 0 && strpos($acceptType[0], "json") !== false ){ + return new JsonResponse(["error" => ["message" => $exception->getMessage(), "type" => "Exception", "trace" => $this->debugMode ? $exception->getTraceAsString() : ""]]); + } + if ($this->contentFor500) { $this->contentBlock = $this->contentFor500; } else { @@ -108,6 +116,8 @@ public function serverError(\Exception $exception) return HtmlResponse::create($this->template, 500); } + + /** * Inludes the file (useful to load a view inside the Controllers scope). *