Skip to content

Commit 5a20685

Browse files
committed
Fix no report validation message when disabled debug
1 parent 7635dd4 commit 5a20685

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Exceptions/Handler.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Inertia\Exceptions;
44

55
use Illuminate\Http\Request;
6+
use Illuminate\Validation\ValidationException;
67
use Inertia\Response as InertiaResponse;
78
use Inertia\ResponseFactory;
89
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
@@ -54,6 +55,10 @@ public function __construct(protected ResponseFactory $inertia)
5455
*/
5556
public function handle(Request $request, SymfonyResponse $response, Throwable $e): SymfonyResponse
5657
{
58+
if ($e instanceof ValidationException && $e->status === 422) {
59+
return $response;
60+
}
61+
5762
$code = $e instanceof HttpExceptionInterface ? $e->getStatusCode() : 500;
5863

5964
$messages = $this->resolveMessages($e);
@@ -63,9 +68,7 @@ public function handle(Request $request, SymfonyResponse $response, Throwable $e
6368
$message = $messageContext['message'];
6469

6570
if (! $request->isMethod('GET') && in_array($code, [419, 429])) {
66-
return back()
67-
->setStatusCode($code)
68-
->with($this->errorMessageKey, $message);
71+
return back()->with($this->errorMessageKey, $message);
6972
}
7073

7174
if (! config('app.debug') && array_key_exists($code, $messages)) {

0 commit comments

Comments
 (0)