|
19 | 19 | use App\Service\KeyVaultService; |
20 | 20 | use Psr\Cache\CacheItemInterface; |
21 | 21 | use Psr\Cache\InvalidArgumentException; |
| 22 | +use Psr\Log\LoggerInterface; |
22 | 23 | use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; |
23 | 24 | use Symfony\Contracts\Cache\CacheInterface; |
24 | 25 | use Symfony\Contracts\HttpClient\HttpClientInterface; |
@@ -62,6 +63,7 @@ public function __construct( |
62 | 63 | private readonly CacheInterface $interactiveSlideCache, |
63 | 64 | private readonly FeedService $feedService, |
64 | 65 | private readonly string $busyIntervalsSource, |
| 66 | + private readonly LoggerInterface $logger, |
65 | 67 | ) { |
66 | 68 | if (!in_array($busyIntervalsSource, [self::SOURCE_GRAPH, self::SOURCE_FEED], true)) { |
67 | 69 | throw new \InvalidArgumentException(sprintf('Invalid INSTANT_BOOK_BUSY_INTERVALS_SOURCE "%s"; expected "%s" or "%s".', $busyIntervalsSource, self::SOURCE_GRAPH, self::SOURCE_FEED)); |
@@ -231,8 +233,10 @@ function (CacheItemInterface $item) use ($slide, $resource, $interactionRequest, |
231 | 233 | $updatedWatchedResources = $watchedResources; |
232 | 234 |
|
233 | 235 | return $result; |
234 | | - } catch (\Throwable) { |
| 236 | + } catch (\Throwable $e) { |
235 | 237 | // All errors should result in empty options. |
| 238 | + $this->logger->error('Failed to compute instant-book options; returning empty options', ['exception' => $e]); |
| 239 | + |
236 | 240 | return $this->createEntry($resource, $start); |
237 | 241 | } |
238 | 242 | } |
@@ -268,7 +272,8 @@ private function createEntry(string $resource, \DateTime $start, ?array $schedul |
268 | 272 | foreach (self::DURATIONS as $durationMinutes) { |
269 | 273 | try { |
270 | 274 | $startPlus = (clone $start)->add(new \DateInterval('PT'.$durationMinutes.'M'))->setTimezone(new \DateTimeZone('UTC')); |
271 | | - } catch (\Exception) { |
| 275 | + } catch (\Exception $e) { |
| 276 | + $this->logger->error('Failed to build instant-book duration interval; skipping duration', ['exception' => $e, 'duration_minutes' => $durationMinutes]); |
272 | 277 | continue; |
273 | 278 | } |
274 | 279 |
|
|
0 commit comments