Skip to content

Commit

Permalink
Fix no report validation message when disabled debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ycs77 committed May 27, 2024
1 parent 7635dd4 commit 5a20685
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Inertia\Exceptions;

use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Inertia\Response as InertiaResponse;
use Inertia\ResponseFactory;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
Expand Down Expand Up @@ -54,6 +55,10 @@ public function __construct(protected ResponseFactory $inertia)
*/
public function handle(Request $request, SymfonyResponse $response, Throwable $e): SymfonyResponse
{
if ($e instanceof ValidationException && $e->status === 422) {
return $response;
}

$code = $e instanceof HttpExceptionInterface ? $e->getStatusCode() : 500;

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

if (! $request->isMethod('GET') && in_array($code, [419, 429])) {
return back()
->setStatusCode($code)
->with($this->errorMessageKey, $message);
return back()->with($this->errorMessageKey, $message);
}

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

0 comments on commit 5a20685

Please sign in to comment.