Show proper 404 page for JSON.

This commit is contained in:
James Cole
2018-02-10 09:57:56 +01:00
parent 4eb010f807
commit 523ae83811

View File

@@ -27,6 +27,7 @@ use Exception;
use FireflyIII\Jobs\MailError;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Handler
@@ -62,6 +63,10 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
return response()->json(['message' => 'Not found'], 404);
}
if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
$isDebug = env('APP_DEBUG', false);