Specify explicit duplicate key exception in DB class

This commit is contained in:
Alex Cabal 2024-04-26 13:58:05 -05:00
parent 265db89448
commit 07110829e7
2 changed files with 7 additions and 1 deletions

View file

@ -133,7 +133,7 @@ class DbConnection{
} }
elseif($ex->getCode() == '23000'){ elseif($ex->getCode() == '23000'){
// Duplicate key, bubble this up without logging it so the business logic can handle it // Duplicate key, bubble this up without logging it so the business logic can handle it
throw($ex); throw new Exceptions\DuplicateDatabaseKeyException();
} }
else{ else{
$done = true; $done = true;

View file

@ -0,0 +1,6 @@
<?
namespace Exceptions;
class DuplicateDatabaseKeyException extends AppException{
protected $message = 'An attempted row insertion has violated the database unique index.';
}