diff --git a/app/Exceptions/Http/Connection/DaemonConnectionException.php b/app/Exceptions/Http/Connection/DaemonConnectionException.php index ffeede718..342fd7a24 100644 --- a/app/Exceptions/Http/Connection/DaemonConnectionException.php +++ b/app/Exceptions/Http/Connection/DaemonConnectionException.php @@ -5,6 +5,7 @@ namespace App\Exceptions\Http\Connection; use Illuminate\Http\Response; use GuzzleHttp\Exception\GuzzleException; use App\Exceptions\DisplayException; +use Illuminate\Support\Facades\Context; /** * @method \GuzzleHttp\Exception\GuzzleException getPrevious() @@ -30,6 +31,8 @@ class DaemonConnectionException extends DisplayException $response = method_exists($previous, 'getResponse') ? $previous->getResponse() : null; $this->requestId = $response?->getHeaderLine('X-Request-Id'); + Context::add('request_id', $this->requestId); + if ($useStatusCode) { $this->statusCode = is_null($response) ? $this->statusCode : $response->getStatusCode(); // There are rare conditions where daemon encounters a panic condition and crashes the @@ -63,17 +66,6 @@ class DaemonConnectionException extends DisplayException parent::__construct($message, $previous, $level); } - /** - * Override the default reporting method for DisplayException by just logging immediately - * here and including the specific X-Request-Id header that was returned by the call. - */ - public function report() - { - logger()->{$this->getErrorLevel()}($this->getPrevious(), [ - 'request_id' => $this->requestId, - ]); - } - /** * Return the HTTP status code for this exception. */ @@ -81,9 +73,4 @@ class DaemonConnectionException extends DisplayException { return $this->statusCode; } - - public function getRequestId(): ?string - { - return $this->requestId; - } }