From bd1e902f38f548c127d31cb6ec170973d95e315d Mon Sep 17 00:00:00 2001 From: Kevin Robatel Date: Fri, 17 Jul 2015 09:37:51 +0200 Subject: [PATCH] catch exceptions when accessing the storage --- src/PrivateCache.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PrivateCache.php b/src/PrivateCache.php index 6fcbeb94..33afdf28 100644 --- a/src/PrivateCache.php +++ b/src/PrivateCache.php @@ -83,7 +83,11 @@ protected function getCacheKey(RequestInterface $request) */ public function fetch(RequestInterface $request) { - return $this->storage->fetch($this->getCacheKey($request)); + try { + return $this->storage->fetch($this->getCacheKey($request)); + } catch (\Exception $ignored) { + return null; + } } /** @@ -93,6 +97,10 @@ public function fetch(RequestInterface $request) */ public function cache(RequestInterface $request, ResponseInterface $response) { - return $this->storage->save($this->getCacheKey($request), $this->getCacheObject($response)); + try { + return $this->storage->save($this->getCacheKey($request), $this->getCacheObject($response)); + } catch (\Exception $ignored) { + return false; + } } }