Repository navigation
Replies: 2 comments
|
You are not using the API incorrectly. On the affected Laravel 12 releases this was a framework lifecycle issue: the The framework fix is in laravel/framework#57759, linked from issue #57601. The preferred solution is therefore to upgrade to a Laravel framework release containing that fix. If you must remain on an affected release, call the underlying static setting earlier, for example in use Illuminate\Http\Client\RequestException;
public function boot(): void
{
RequestException::dontTruncate();
}That runs before application code normally sends HTTP requests, avoiding the ordering problem. If the application uses long-lived workers such as Octane or queue workers, restart them after making the change. |
|
It goes inside the ->withExceptions(function (Exceptions $exceptions) {
$exceptions->dontTruncateRequestExceptions();
// or a custom length instead:
// $exceptions->truncateRequestExceptionsAt(500);
})One thing that tripped me up: this only applies to Also note it only changes what gets reported/logged; the exception message itself is the same. If it's still truncated after configuring, make sure you're on a version that has the method (added in 11.x) and that the exception you're inspecting is actually an HTTP client — |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have a hard time understanding how to make it work properly.
Quote from docs:
bootstrap/app.php
routes/web.php
Result
In the example above, execution will happen in the following order:
\Illuminate\Foundation\Configuration\ApplicationBuilder::withExceptions()which stores a callable that will be executed after resolving\Illuminate\Foundation\Exceptions\Handler\Illuminate\Http\Client\Response::throw()\Illuminate\Http\Client\Response::toException()\Illuminate\Http\Client\RequestException::prepareMessage()<--- truncates response body\Illuminate\Foundation\Exceptions\Handler::__construct()\Illuminate\Foundation\Exceptions\Handler(callable passed toApplicationBuilder::withExceptions())\Illuminate\Foundation\Configuration\Exceptions::dontTruncateRequestExceptions()<--- configuration forRequestExceptionto not truncate response bodyWhat is the point of that configuration if that call will happen only after the response has already been truncated?
Am I missing how to use it correctly?
All reactions