Do not use the strict operator as suggested when checking the Exception Code in \PDOException.
As per documentation: \PDOException is returning a string for its Exception Code and not an Integer.
Ran into the following in PHP8:
<?php
catch(\PDOException $e) {
var_dump($e->getCode()); //Output: string(5) "23000"
}
?>