Skip to content

Commit

Permalink
Address comments on #2492 (#2501)
Browse files Browse the repository at this point in the history
* Adjust handling of TerminusCollection items lacking useful data

* Add comment clarifying handling of null response object
  • Loading branch information
namespacebrian authored Sep 20, 2023
1 parent 74852be commit b62cbb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Collections/TerminusCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit b62cbb9

Please sign in to comment.