From b62cbb97d027a0889fd7c8eac9396ebe4a842223 Mon Sep 17 00:00:00 2001 From: Brian Weaver <87093053+namespacebrian@users.noreply.github.com> Date: Wed, 20 Sep 2023 16:02:15 -0400 Subject: [PATCH] Address comments on #2492 (#2501) * Adjust handling of TerminusCollection items lacking useful data * Add comment clarifying handling of null response object --- src/Collections/TerminusCollection.php | 12 ++++++++++-- src/Request/Request.php | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Collections/TerminusCollection.php b/src/Collections/TerminusCollection.php index a034b7af6..c2c427d0a 100644 --- a/src/Collections/TerminusCollection.php +++ b/src/Collections/TerminusCollection.php @@ -109,8 +109,16 @@ public function fetch() 'type' => gettype($model_data), 'bad_data' => $bad_data ]; - $this->logger->error($error_message, $context); - break; + + // verbose logging for debugging + $this->logger->debug($error_message, $context); + + // less information for more user-facing messages, but a problem has occurred and we're skipping this + // item so we should still surface a user-facing message + $this->logger->warn("Model data missing for {id}", ['id' => $id,]); + + // skip this item since it lacks useful data + continue; } if (!isset($model_data->id)) { $model_data->id = $id; diff --git a/src/Request/Request.php b/src/Request/Request.php index be42f268b..1ec7274a4 100755 --- a/src/Request/Request.php +++ b/src/Request/Request.php @@ -244,6 +244,7 @@ private function createRetryDecider(): callable } } + // It's been observed in the wild that sometimes $response is null. Get a different error message in that case. if (is_object($response) && is_object($response->getBody()) && $response->getBody()->getContents() !== '') { $error = $response->getBody()->getContents(); } elseif (null !== $exception && '' != $exception->getMessage()) {