Added catch for validation exception specifically

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2025-05-13 20:41:22 +02:00
parent b5dc39e70e
commit b65cb967be
2 changed files with 22 additions and 1 deletions
+7 -1
View File
@@ -121,7 +121,13 @@ class Handler extends ExceptionHandler
// This handles API validation exceptions that happen at the Form Request level, so they
// never even get to the controller where we normally nicely format JSON responses
return response()->json(Helper::formatStandardApiResponse('error', null, $e->errors()), 200);
if ($e instanceof ValidationException) {
$response = $this->invalidJson($request, $e);
return response()->json(Helper::formatStandardApiResponse('error', null, $e->errors()), 200);
}
return response()->json(Helper::formatStandardApiResponse('error', null, 'Undefined exception'), 200);
}