feat(errors): global QueryException handler returns human message

This commit is contained in:
Дмитрий
2026-05-21 06:42:38 +03:00
parent 472ea8c75c
commit f3250ce178
3 changed files with 124 additions and 1 deletions
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Route;
it('renders QueryException as human JSON message, not SQLSTATE', function () {
Route::get('/_test/boom-query', function () {
throw new QueryException('pgsql', 'SELECT 1', [], new Exception('SQLSTATE[23505] duplicate key'));
});
$res = $this->getJson('/_test/boom-query');
$res->assertStatus(422);
expect($res->json('message'))->not->toContain('SQLSTATE');
expect($res->json('message'))->toContain('Не удалось');
});