From c0fd047ca8816b7ec3f24e2260347a57b92c8630 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Thu, 20 Nov 2025 20:34:51 -0500 Subject: [PATCH 1/4] Update RequestException.php --- src/Illuminate/Http/Client/RequestException.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Http/Client/RequestException.php b/src/Illuminate/Http/Client/RequestException.php index 1bdd38503c8a..4f9a711303af 100644 --- a/src/Illuminate/Http/Client/RequestException.php +++ b/src/Illuminate/Http/Client/RequestException.php @@ -83,9 +83,9 @@ public static function dontTruncate() /** * Prepare the exception message. * - * @return void + * @return bool */ - public function report(): void + public function report() { if ($this->hasBeenSummarized) { return; @@ -94,6 +94,8 @@ public function report(): void $this->message = $this->prepareMessage($this->response); $this->hasBeenSummarized = true; + + return false; } /** From c66054354e8d674db7bad54ca051bac11f9a97ee Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Thu, 20 Nov 2025 20:56:31 -0500 Subject: [PATCH 2/4] test --- .../Foundation/ExceptionHandlerTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/Integration/Foundation/ExceptionHandlerTest.php b/tests/Integration/Foundation/ExceptionHandlerTest.php index b4a52ecee635..942f8984179a 100644 --- a/tests/Integration/Foundation/ExceptionHandlerTest.php +++ b/tests/Integration/Foundation/ExceptionHandlerTest.php @@ -9,10 +9,17 @@ use Illuminate\Contracts\Debug\ShouldntReport; use Illuminate\Contracts\Routing\ResponseFactory as ResponseFactoryContract; use Illuminate\Contracts\Support\Responsable; +use Illuminate\Http\Client\RequestException; use Illuminate\Http\JsonResponse; use Illuminate\Routing\ResponseFactory; use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\Exceptions; +use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Route; +use Illuminate\Support\Testing\Fakes\ExceptionHandlerFake; +use Mockery; +use Monolog\Handler\TestHandler; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\DataProvider; use Symfony\Component\Process\PhpProcess; @@ -281,4 +288,30 @@ public function json($data = [], $status = 200, array $headers = [], $options = 'success' => false, ]); } + + public function test_it_reports_request_exceptions() + { + //Exceptions::fake(); + config(['logging.default' => 'test_log']); + config(['logging.channels.test_log' => [ + 'driver' => 'monolog', + 'handler' => TestHandler::class, + ]]); + Log::setDefaultDriver('test_log'); + Http::fake([ + '*' => Http::response('a really long message is being returned', status:500), + ]); + + RequestException::truncateAt(8); + try { + Http::throw()->get('http://laravel.test'); + } catch (RequestException $requestException) { + report($requestException); + } + + $recordedLogs = Log::getLogger()->getHandlers()[0]->getRecords(); + $this->assertCount(1, $recordedLogs); + $this->assertStringContainsString('a really (truncated...)', $recordedLogs[0]['message']); + } } + From c839e3c6d3b58ec02bc59648bfab8cc244fa3f6d Mon Sep 17 00:00:00 2001 From: Luke Kuzmish <42181698+cosmastech@users.noreply.github.com> Date: Thu, 20 Nov 2025 21:47:30 -0500 Subject: [PATCH 3/4] Update RequestException.php --- src/Illuminate/Http/Client/RequestException.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Http/Client/RequestException.php b/src/Illuminate/Http/Client/RequestException.php index 4f9a711303af..fc6641f3786c 100644 --- a/src/Illuminate/Http/Client/RequestException.php +++ b/src/Illuminate/Http/Client/RequestException.php @@ -87,13 +87,11 @@ public static function dontTruncate() */ public function report() { - if ($this->hasBeenSummarized) { - return; - } - - $this->message = $this->prepareMessage($this->response); + if (! $this->hasBeenSummarized) { + $this->message = $this->prepareMessage($this->response); - $this->hasBeenSummarized = true; + $this->hasBeenSummarized = true; + } return false; } From fa451feb3e4a1b229c74a637a93d5899c0e2e6b2 Mon Sep 17 00:00:00 2001 From: Luke Kuzmish Date: Thu, 20 Nov 2025 21:52:37 -0500 Subject: [PATCH 4/4] clean --- tests/Integration/Foundation/ExceptionHandlerTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/Integration/Foundation/ExceptionHandlerTest.php b/tests/Integration/Foundation/ExceptionHandlerTest.php index 942f8984179a..2dac2d9658d9 100644 --- a/tests/Integration/Foundation/ExceptionHandlerTest.php +++ b/tests/Integration/Foundation/ExceptionHandlerTest.php @@ -13,12 +13,9 @@ use Illuminate\Http\JsonResponse; use Illuminate\Routing\ResponseFactory; use Illuminate\Support\Facades\Config; -use Illuminate\Support\Facades\Exceptions; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Route; -use Illuminate\Support\Testing\Fakes\ExceptionHandlerFake; -use Mockery; use Monolog\Handler\TestHandler; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\DataProvider; @@ -291,7 +288,6 @@ public function json($data = [], $status = 200, array $headers = [], $options = public function test_it_reports_request_exceptions() { - //Exceptions::fake(); config(['logging.default' => 'test_log']); config(['logging.channels.test_log' => [ 'driver' => 'monolog',