From beab726fd077a1334b8ace507b019efcee322913 Mon Sep 17 00:00:00 2001 From: Philippe Thiers Date: Thu, 22 Oct 2020 14:02:41 -0300 Subject: [PATCH] Catch Service Exception from the oauth connection of gcloud --- .gitignore | 5 +++++ src/StackdriverHandler.php | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a5d56ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +### Composer template +composer.phar +/vendor/ +composer.lock + diff --git a/src/StackdriverHandler.php b/src/StackdriverHandler.php index 2740909..356b60d 100644 --- a/src/StackdriverHandler.php +++ b/src/StackdriverHandler.php @@ -75,7 +75,13 @@ protected function write(array $record): void $entry = $this->logger->entry($data, $options); - $this->logger->write($entry); + try{ + $this->logger->write($entry); + } catch (\Google\Cloud\Core\Exception\ServiceException $exception) { + error_log("Error connecting to Google services: " . $exception->getMessage()); + } catch(\Exception $exception) { + throw $exception; + } } /**