Expand API.

This commit is contained in:
James Cole
2018-02-13 18:24:06 +01:00
parent 30f821af3e
commit 370e9b25d1
12 changed files with 405 additions and 46 deletions

View File

@@ -28,7 +28,7 @@ use FireflyIII\Jobs\MailError;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Validation\ValidationException;
/**
* Class Handler
*/
@@ -63,6 +63,10 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if ($exception instanceof ValidationException && $request->expectsJson()) {
// ignore it: controller will handle it.
return parent::render($request, $exception);
}
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
}