Rename exception for consistency

This commit is contained in:
Alex Cabal 2025-01-09 14:08:54 -06:00
parent 94d62fdcdf
commit c36d1ac3d3
4 changed files with 10 additions and 10 deletions

View file

@ -1550,7 +1550,7 @@ final class Ebook{
/** /**
* @throws Exceptions\InvalidEbookException * @throws Exceptions\InvalidEbookException
* @throws Exceptions\DuplicateEbookException * @throws Exceptions\EbookExistsException
*/ */
public function CreateOrUpdate(): void{ public function CreateOrUpdate(): void{
try{ try{
@ -1838,14 +1838,14 @@ final class Ebook{
/** /**
* @throws Exceptions\InvalidEbookException * @throws Exceptions\InvalidEbookException
* @throws Exceptions\DuplicateEbookException If an `Ebook` with the given identifier already exists. * @throws Exceptions\EbookExistsException If an `Ebook` with the given identifier already exists.
*/ */
public function Create(): void{ public function Create(): void{
$this->Validate(); $this->Validate();
try{ try{
Ebook::GetByIdentifier($this->Identifier); Ebook::GetByIdentifier($this->Identifier);
throw new Exceptions\DuplicateEbookException($this->Identifier); throw new Exceptions\EbookExistsException($this->Identifier);
} }
catch(Exceptions\EbookNotFoundException){ catch(Exceptions\EbookNotFoundException){
// Pass. // Pass.
@ -1917,7 +1917,7 @@ final class Ebook{
/** /**
* @throws Exceptions\InvalidEbookException If the `Ebook` is invalid. * @throws Exceptions\InvalidEbookException If the `Ebook` is invalid.
* @throws Exceptions\DuplicateEbookException If an `Ebook` with the same title and author already exists. * @throws Exceptions\EbookExistsException If an `Ebook` with the same title and author already exists.
*/ */
public function Save(): void{ public function Save(): void{
$this->Validate(); $this->Validate();
@ -1970,7 +1970,7 @@ final class Ebook{
$this->EbookId]); $this->EbookId]);
} }
catch(Exceptions\DuplicateDatabaseKeyException){ catch(Exceptions\DuplicateDatabaseKeyException){
throw new Exceptions\DuplicateEbookException($this->Identifier); throw new Exceptions\EbookExistsException($this->Identifier);
} }

View file

@ -1,7 +1,7 @@
<? <?
namespace Exceptions; namespace Exceptions;
class DuplicateEbookException extends AppException{ class EbookExistsException extends AppException{
public function __construct(string $identifier){ public function __construct(string $identifier){
$this->message = 'Ebook already exists with identifier: ' . $identifier; $this->message = 'Ebook already exists with identifier: ' . $identifier;

View file

@ -34,7 +34,7 @@ try{
try{ try{
$ebook->Create(); $ebook->Create();
} }
catch(Exceptions\DuplicateEbookException $ex){ catch(Exceptions\EbookExistsException $ex){
$ebook = Ebook::GetByIdentifier($ebook->Identifier); $ebook = Ebook::GetByIdentifier($ebook->Identifier);
// An existing `EbookPlaceholder` already exists. // An existing `EbookPlaceholder` already exists.
@ -72,7 +72,7 @@ try{
try{ try{
$ebook->Save(); $ebook->Save();
} }
catch(Exceptions\DuplicateEbookException){ catch(Exceptions\EbookExistsException){
throw new Exceptions\EbookPlaceholderExistsException(); throw new Exceptions\EbookPlaceholderExistsException();
} }

View file

@ -35,7 +35,7 @@ try{
$project->Ebook->Create(); $project->Ebook->Create();
$project->EbookId = $project->Ebook->EbookId; $project->EbookId = $project->Ebook->EbookId;
} }
catch(Exceptions\DuplicateEbookException $ex){ catch(Exceptions\EbookExistsException $ex){
// If the `Ebook` already exists, create the `Project` anyway. // If the `Ebook` already exists, create the `Project` anyway.
$project->Ebook = Ebook::GetByIdentifier($project->Ebook->Identifier); $project->Ebook = Ebook::GetByIdentifier($project->Ebook->Identifier);
if($project->Ebook->EbookPlaceholder !== null && !$project->Ebook->EbookPlaceholder->IsInProgress){ if($project->Ebook->EbookPlaceholder !== null && !$project->Ebook->EbookPlaceholder->IsInProgress){
@ -90,7 +90,7 @@ catch(Exceptions\LoginRequiredException){
catch(Exceptions\InvalidPermissionsException){ catch(Exceptions\InvalidPermissionsException){
Template::ExitWithCode(Enums\HttpCode::Forbidden); Template::ExitWithCode(Enums\HttpCode::Forbidden);
} }
catch(Exceptions\InvalidProjectException | Exceptions\InvalidEbookException | Exceptions\ProjectExistsException | Exceptions\DuplicateEbookException | Exceptions\EbookIsNotAPlaceholderException $ex){ catch(Exceptions\InvalidProjectException | Exceptions\InvalidEbookException | Exceptions\ProjectExistsException | Exceptions\EbookExistsException | Exceptions\EbookIsNotAPlaceholderException $ex){
$_SESSION['project'] = $project; $_SESSION['project'] = $project;
$_SESSION['exception'] = $ex; $_SESSION['exception'] = $ex;