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\DuplicateEbookException
* @throws Exceptions\EbookExistsException
*/
public function CreateOrUpdate(): void{
try{
@ -1838,14 +1838,14 @@ final class Ebook{
/**
* @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{
$this->Validate();
try{
Ebook::GetByIdentifier($this->Identifier);
throw new Exceptions\DuplicateEbookException($this->Identifier);
throw new Exceptions\EbookExistsException($this->Identifier);
}
catch(Exceptions\EbookNotFoundException){
// Pass.
@ -1917,7 +1917,7 @@ final class Ebook{
/**
* @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{
$this->Validate();
@ -1970,7 +1970,7 @@ final class Ebook{
$this->EbookId]);
}
catch(Exceptions\DuplicateDatabaseKeyException){
throw new Exceptions\DuplicateEbookException($this->Identifier);
throw new Exceptions\EbookExistsException($this->Identifier);
}

View file

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

View file

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

View file

@ -35,7 +35,7 @@ try{
$project->Ebook->Create();
$project->EbookId = $project->Ebook->EbookId;
}
catch(Exceptions\DuplicateEbookException $ex){
catch(Exceptions\EbookExistsException $ex){
// If the `Ebook` already exists, create the `Project` anyway.
$project->Ebook = Ebook::GetByIdentifier($project->Ebook->Identifier);
if($project->Ebook->EbookPlaceholder !== null && !$project->Ebook->EbookPlaceholder->IsInProgress){
@ -90,7 +90,7 @@ catch(Exceptions\LoginRequiredException){
catch(Exceptions\InvalidPermissionsException){
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['exception'] = $ex;