Skip to content

Commit eb373eb

Browse files
committed
fix: Handle all exceptions within Guzzle feature requester
fixes #225
1 parent d22efb2 commit eb373eb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace LaunchDarkly\Impl\Integrations;
66

7+
use Exception;
78
use GuzzleHttp\Client;
89
use GuzzleHttp\Exception\BadResponseException;
910
use GuzzleHttp\HandlerStack;
@@ -75,6 +76,9 @@ public function getFeature(string $key): ?FeatureFlag
7576
$this->handleUnexpectedStatus($code, "GuzzleFeatureRequester::get");
7677
}
7778
return null;
79+
} catch (Exception $e) {
80+
$this->_logger->error("GuzzleFeatureRequester::get encountered an exception retrieving flag key {$key}: " . $e->getMessage());
81+
return null;
7882
}
7983
}
8084

@@ -99,6 +103,9 @@ public function getSegment(string $key): ?Segment
99103
$this->handleUnexpectedStatus($code, "GuzzleFeatureRequester::get");
100104
}
101105
return null;
106+
} catch (Exception $e) {
107+
$this->_logger->error("GuzzleFeatureRequester::get encountered an exception retrieving segment key {$key}: " . $e->getMessage());
108+
return null;
102109
}
103110
}
104111

@@ -117,6 +124,9 @@ public function getAllFeatures(): ?array
117124
/** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */
118125
$this->handleUnexpectedStatus($e->getResponse()->getStatusCode(), "GuzzleFeatureRequester::getAll");
119126
return null;
127+
} catch (Exception $e) {
128+
$this->_logger->error("GuzzleFeatureRequester::getAll encountered an exception retrieving all flags: " . $e->getMessage());
129+
return null;
120130
}
121131
}
122132

0 commit comments

Comments
 (0)