Here is something interesting regarding a PDOException and it involves some of the annoyances that can be associated with PHP's dynamic nature. PDOException extends from RuntimeException, which in return extends from Exception. As such, it has access to the $code Protected Class Variable, which represents the Exception's code as an Integer (duh!) and can be accessed externally using the Exception: