From 0138b19000dfad61bd20bca87462748e9ef01c10 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Thu, 31 Oct 2024 13:55:25 -0600 Subject: [PATCH] Make Artwork robust to EbookNotFoundException This probably means the Ebook is unreleased, but the artwork page can still show the EbookUrl. Found this error during testing of the ebook DB here: https://github.com/standardebooks/web/pull/401#issuecomment-2450588117 --- lib/Artwork.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Artwork.php b/lib/Artwork.php index 0e2ac217..136e0cc0 100644 --- a/lib/Artwork.php +++ b/lib/Artwork.php @@ -258,9 +258,6 @@ class Artwork{ return $this->_Dimensions; } - /** - * @throws Exceptions\EbookNotFoundException - */ protected function GetEbook(): ?Ebook{ if($this->_Ebook === null){ if($this->EbookUrl === null){ @@ -268,7 +265,13 @@ class Artwork{ } $identifier = 'url:' . $this->EbookUrl; - $this->_Ebook = Ebook::GetByIdentifier($identifier); + try{ + $this->_Ebook = Ebook::GetByIdentifier($identifier); + } + catch(Exceptions\EbookNotFoundException){ + // The ebook is probably unreleased. + return null; + } } return $this->_Ebook;