Skip to content

Commit fde90f9

Browse files
authored
Get more context with error logs (#656)
1 parent 5c0a2b8 commit fde90f9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Response.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,20 +357,22 @@ private function getResolveStatus(): bool
357357
$this->resolveResult = new $class(...$args);
358358
}
359359

360+
$message = null;
361+
$context = ['exception' => $this->resolveResult];
360362
if ($this->resolveResult instanceof HttpException) {
361363
/** @var int $code */
362364
$code = $this->httpResponse->getInfo('http_code');
363365
/** @var string $url */
364366
$url = $this->httpResponse->getInfo('url');
365-
$this->logger->error(sprintf('HTTP %d returned for "%s".', $code, $url), [
366-
'aws_code' => $this->resolveResult->getAwsCode(),
367-
'aws_message' => $this->resolveResult->getAwsMessage(),
368-
'aws_type' => $this->resolveResult->getAwsType(),
369-
'aws_detail' => $this->resolveResult->getAwsDetail(),
370-
]);
367+
$context['aws_code'] = $this->resolveResult->getAwsCode();
368+
$context['aws_message'] = $this->resolveResult->getAwsMessage();
369+
$context['aws_type'] = $this->resolveResult->getAwsType();
370+
$context['aws_detail'] = $this->resolveResult->getAwsDetail();
371+
$message = sprintf('HTTP %d returned for "%s".', $code, $url);
371372
}
372373

373374
if ($this->resolveResult instanceof Exception) {
375+
$this->logger->error($message ?? $this->resolveResult->getMessage(), $context);
374376
$this->didThrow = true;
375377

376378
throw $this->resolveResult;

0 commit comments

Comments
 (0)