Skip to content

Commit 63dffde

Browse files
authored
Fix truncation usage for RequestException (#10912)
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`.
1 parent 293ca60 commit 63dffde

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

http-client.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,17 @@ return Http::post(/* ... */)->throw(function (Response $response, RequestExcepti
397397
})->json();
398398
```
399399

400-
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:
400+
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:
401401

402402
```php
403-
use Illuminate\Foundation\Configuration\Exceptions;
403+
use Illuminate\Http\Client\RequestException;
404404

405-
->withExceptions(function (Exceptions $exceptions): void {
405+
->registered(function (): void {
406406
// Truncate request exception messages to 240 characters...
407-
$exceptions->truncateRequestExceptionsAt(240);
407+
RequestException::truncateAt(240);
408408

409409
// Disable request exception message truncation...
410-
$exceptions->dontTruncateRequestExceptions();
410+
RequestException::dontTruncate();
411411
})
412412
```
413413

0 commit comments

Comments
 (0)