I was curious if there is a way we can check if there is a constraint violation error when delete or insert a record into the database.
The exception thrown is called \'
You may also try
try { ... } catch ( \Exception $e) { var_dump($e->errorInfo ); }
then look for error code.
This catches all exception including QueryException