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
This commit is contained in:
Mike Colagrosso 2024-10-31 13:55:25 -06:00 committed by Alex Cabal
parent 7e67e108f3
commit 0138b19000

View file

@ -258,9 +258,6 @@ class Artwork{
return $this->_Dimensions; return $this->_Dimensions;
} }
/**
* @throws Exceptions\EbookNotFoundException
*/
protected function GetEbook(): ?Ebook{ protected function GetEbook(): ?Ebook{
if($this->_Ebook === null){ if($this->_Ebook === null){
if($this->EbookUrl === null){ if($this->EbookUrl === null){
@ -268,7 +265,13 @@ class Artwork{
} }
$identifier = 'url:' . $this->EbookUrl; $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; return $this->_Ebook;