diff --git a/app/AbstractUseStaleRequest.php b/app/AbstractUseStaleRequest.php index 279f665..82697c3 100644 --- a/app/AbstractUseStaleRequest.php +++ b/app/AbstractUseStaleRequest.php @@ -33,8 +33,8 @@ protected function responseFromCache(): ?Response ->setReadCache(false) ->setWriteCache(true) ->sync(); - } catch (\Throwable) { - // Nobody cares, this is literally what use-stale is good at + } catch (\Throwable $e) { + $reRequest->onBackgroundRefreshFailed($e); } }); } @@ -78,6 +78,8 @@ public function purgeCache(): self return parent::purgeCache(); } + protected function onBackgroundRefreshFailed(\Throwable $e): void {} + // Children of this class are *required* to thoughtfully implement their own PHP 8.1+ style serialization, // to work with `dispatch` in `responseFromCache` // https://php.watch/versions/8.1/serializable-deprecated