截断由 Guzzle 库完成。它仅显示响应的前 120 个字符。我假设这是因为回复可能很长。
如果要查看完整的消息,应该能够自定义如何处理大量异常。
将中的方法更新为如下所示:report()
app/Exceptions/Handler.php
public function report(Exception $exception)
{
// this is from the parent method
if ($this->shouldntReport($exception)) {
return;
}
// this is from the parent method
try {
$logger = $this->container->make(\Psr\Log\LoggerInterface::class);
} catch (Exception $ex) {
throw $exception; // throw the original exception
}
// this is the new custom handling of guzzle exceptions
if ($exception instanceof \GuzzleHttp\Exception\RequestException) {
// get the full text of the exception (including stack trace),
// and replace the original message (possibly truncated),
// with the full text of the entire response body.
$message = str_replace(
rtrim($exception->getMessage()),
(string) $exception->getResponse()->getBody(),
(string) $exception
);
// log your new custom guzzle error message
return $logger->error($message);
}
// make sure to still log non-guzzle exceptions
$logger->error($exception);
}
注意:这是在方法中完成的,因此它只影响写入日志的内容。如果将异常转储到终端或浏览器,它仍将显示截断的消息。report