Exemple #1
0
        internal void HandleError(System.Exception ex)
        {
            // fill errorInfo
            Driver.HandleException(ex, out _errorSqlState, out _errorCode, out _errorMessage);

            //
            PDO_ERRMODE mode = (PDO_ERRMODE)this.m_attributes[PDO_ATTR.ATTR_ERRMODE].ToLong();

            switch (mode)
            {
            case PDO_ERRMODE.ERRMODE_SILENT:
                break;

            case PDO_ERRMODE.ERRMODE_WARNING:
                PhpException.Throw(PhpError.E_WARNING, ex.Message);
                break;

            case PDO_ERRMODE.ERRMODE_EXCEPTION:
                if (ex is Pchp.Library.Spl.Exception pex)
                {
                    throw new PDOException(pex.Message, pex.getCode(), pex);
                }
                else
                {
                    throw new PDOException(ex.GetType().Name + ": " + ex.Message);
                }
            }
        }
Exemple #2
0
        public void HandleError(System.Exception ex)
        {
            PDO_ERRMODE mode = (PDO_ERRMODE)this.m_attributes[PDO_ATTR.ATTR_ERRMODE].ToLong();

            //TODO : fill errorCode and errorInfo
            switch (mode)
            {
            case PDO_ERRMODE.ERRMODE_SILENT:
                break;

            case PDO_ERRMODE.ERRMODE_WARNING:
                this.m_ctx.Throw(PhpError.E_WARNING, ex.Message);
                break;

            case PDO_ERRMODE.ERRMODE_EXCEPTION:
                if (ex is Pchp.Library.Spl.Exception)
                {
                    var pex = (Pchp.Library.Spl.Exception)ex;
                    throw new PDOException(pex.Message, pex.getCode(), pex);
                }
                else
                {
                    throw new PDOException(ex.GetType().Name + ": " + ex.Message);
                }
            }
        }