From 10506f43e451b8be0cc9efaf2b0a02c5073f9f53 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Thu, 13 Nov 2025 20:28:08 +0800 Subject: [PATCH] Fix truncation usage for `RequestException` This show a working example on how to setup truncation in `bootstrap/app.php` as the previous code usage doesn't work on web request. > `ApplicationBuilder::withExceptions($using)` method only resolves the `$using` callback after resolving `Illuminate\Foundation\Exceptions\Handler`. Therefore, any value set via `new RequestException($response)` will only consist of resolved `prepareMessage()` value before `Handler`. --- http-client.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/http-client.md b/http-client.md index 5785285fd3..6670ae3c06 100644 --- a/http-client.md +++ b/http-client.md @@ -397,17 +397,17 @@ return Http::post(/* ... */)->throw(function (Response $response, RequestExcepti })->json(); ``` -By default, `RequestException` messages are truncated to 120 characters when logged or reported. To customize or disable this behavior, you may utilize the `truncateRequestExceptionsAt` and `dontTruncateRequestExceptions` methods when configuring your application's exception handling behavior in your `bootstrap/app.php` file: +By default, `RequestException` messages are truncated to 120 characters when logged or reported. To customize or disable this behavior, you may utilize the `truncateAt` and `dontTruncate` methods when configuring your application's registered behavior in your `bootstrap/app.php` file: ```php -use Illuminate\Foundation\Configuration\Exceptions; +use Illuminate\Http\Client\RequestException; -->withExceptions(function (Exceptions $exceptions): void { +->registered(function (): void { // Truncate request exception messages to 240 characters... - $exceptions->truncateRequestExceptionsAt(240); + RequestException::truncateAt(240); // Disable request exception message truncation... - $exceptions->dontTruncateRequestExceptions(); + RequestException::dontTruncate(); }) ```