Use new duplicate key exception instead of checking PDOException

This commit is contained in:
Alex Cabal 2024-04-29 11:50:52 -05:00
parent 5ee7e8e2ad
commit 49f5bc7641
4 changed files with 14 additions and 29 deletions

View file

@ -56,14 +56,8 @@ class NewsletterSubscription extends Accessor{
?)
', [$this->User->UserId, false, $this->IsSubscribedToNewsletter, $this->IsSubscribedToSummary, $this->Created]);
}
catch(PDOException $ex){
if(($ex->errorInfo[1] ?? 0) == 1062){
// Duplicate unique key; email already in use
throw new Exceptions\NewsletterSubscriptionExistsException();
}
else{
throw $ex;
}
catch(Exceptions\DuplicateDatabaseKeyException){
throw new Exceptions\NewsletterSubscriptionExistsException();
}
// Send the double opt-in confirmation email