diff --git a/api/app/Exceptions/Handler.php b/api/app/Exceptions/Handler.php index 8e7fbd1..89610dd 100644 --- a/api/app/Exceptions/Handler.php +++ b/api/app/Exceptions/Handler.php @@ -3,6 +3,7 @@ namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; +use Illuminate\Validation\ValidationException; use Throwable; class Handler extends ExceptionHandler @@ -37,5 +38,11 @@ class Handler extends ExceptionHandler $this->reportable(function (Throwable $e) { // }); + $this->renderable(function (ValidationException $e) { + return response()->json([ + 'code' => ErrorCode('ARGS'), + 'error' => $e->errors()[0] ?? $e->getMessage() + ], $e->status); + }); } }