この問題はLaravel 11.35で解決されます! 2つの新しい方法では、例外の切り捨てを正確に制御します。 それらを
:に追加するだけです
bootstrap/app.php
// bootstrap/app.php use Illuminate\Http\Client\RequestException; return Application::configure(basePath: dirname(__DIR__)) // ... ->withExceptions(function (Exceptions $exceptions) { $exceptions->dontTruncateRequestExceptions(); // Completely disable truncation // Or... $exceptions->truncateRequestExceptionsAt(260); // Set a custom truncation length })->create();
LaravelのHTTPクライアント内の例外処理と切り捨ての詳細については、Laravelの公式ドキュメントを参照してください。 Laravel11.35.0!
try { $response = Http::throws()->get('https://api.example.com/some-error'); // ... } catch (\Illuminate\Http\Client\RequestException $e) { Log::error('HTTP Error', [ 'message' => $e->getMessage(), // Truncated or not, depending on your setting 'response' => $e->response->json(), 'status' => $e->response->status(), // ... ]); }
以上がHTTPクライアントリクエストの例外の切り捨てをカスタマイズしますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。