Skip to content

A free open source IT asset/license management system

Handle JSON validation errors like 5.4

snipe96e2d74ae3b9
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index b232b8956d..3e35005011 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -117,4 +117,16 @@ class Handler extends ExceptionHandler
return redirect()->guest('login');
}
+
+ /**
+ * Convert a validation exception into a JSON response.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Illuminate\Validation\ValidationException $exception
+ * @return \Illuminate\Http\JsonResponse
+ */
+ protected function invalidJson($request, ValidationException $exception)
+ {
+ return response()->json($exception->errors(), $exception->status);
+ }
}