Since PDOException returns the error code as a string, you need a constructor like the one below if you wish to rethrow the PDOException as a custom exception.
This constructor does not call the parent::__construct which will enforce the int type on the error code, but set the message and code as properties directly on the custom exception object.
<?php
class CustomException extends PDOException {
public function __construct($message=null, $code=null) {
$this->message = $message;
$this->code = $code;
}
}