Continue even after Fatal error: Uncaught exception

Continue even after Fatal error: Uncaught exception

我正在查询 google API,它的下限低得离谱,为 100/天,我得到:

Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET ...

.. 并且脚本在那之后什么都不做。

如何防止它失败并至少保存到那时为止收到的所有数据?我将数据保存在一个数组中:

function searchImages($service, $optParams, $query) {
  $results = $service->cse->listCse($query, $optParams);
  return $results;
}
$descriptionSearch = searchImages($customsearchService, $customsearchService_optParams, $descriptions[$i]);
foreach ($descriptionSearch->items as $item) {
  array_push($list[$item_codes[$i]], strtok($item->link,'?'));
}
function searchImages($service, $optParams, $query) {
  try {
      $results = $service->cse->listCse($query, $optParams);
  }catch (Exception $e) {
      // should log this exception... you can use Log4PHP
      return NULL;
  }
  return $results;
}

$descriptionSearch = searchImages($customsearchService,customsearchService_optParams, $descriptions[$i]);
if (!is_null($descriptionSearch)) {
    foreach ($descriptionSearch->items as $item) {
        array_push($list[$item_codes[$i]], strtok($item->link,'?'));
    }
}