PDO4You\PDO4You::getErrorInfo PHP Method

getErrorInfo() private static method

Method to capture the error information of an Exception
private static getErrorInfo ( PDOException $e, boolean $debug = false ) : array
$e PDOException Gets the message from the exception thrown
$debug boolean Enables the display of the captured values
return array
    private static function getErrorInfo(\PDOException $e, $debug = false)
    {
        if (defined(static::PDO4YOU_WEBMASTER)) {
            self::fireAlert(self::$exception['critical-error'], $e);
        }
        $info = null;
        $errorInfo = null;
        $message = $e->getMessage();
        preg_match('~SQLSTATE[[]([[:alnum:]]{1,})[]]:?\\s[[]?([[:digit:]]{1,})?[]]?\\s?(.+)~', $message, $errorInfo);
        $info['state'] = isset($errorInfo[1]) ? $errorInfo[1] : null;
        $info['code'] = isset($errorInfo[2]) ? $errorInfo[2] : null;
        $info['message'] = isset($errorInfo[3]) ? $errorInfo[3] : null;
        if ($debug) {
            echo '<pre>', print_r($info), '</pre>';
        }
        return $info;
    }