From 08621215865d9424e53e4e20b331f32ccd4e2305 Mon Sep 17 00:00:00 2001 From: Matthew Baggett Date: Fri, 20 Nov 2020 21:24:27 +0100 Subject: [PATCH] Router failure to write to redis should not cause a crash. --- src/Router/Router.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Router/Router.php b/src/Router/Router.php index ccb8ec1..c21e72b 100644 --- a/src/Router/Router.php +++ b/src/Router/Router.php @@ -3,6 +3,7 @@ namespace Benzine\Router; use Cache\Adapter\Chain\CachePoolChain; +use Cache\Adapter\Common\Exception\CachePoolException; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; use Monolog\Logger; @@ -152,7 +153,12 @@ class Router ->set($this->getRoutes()) ->expiresAfter($this->cacheTTL) ; - $this->cachePoolChain->save($routeItem); + + try { + $this->cachePoolChain->save($routeItem); + }catch(CachePoolException $cachePoolException){ + $this->logger->critical($cachePoolException->getMessage()); + } return $this; }