Source for file Exception.php

Documentation is available at Exception.php

  1. <?php
  2. /*
  3.  *  $Id: Exception.php 1080 2007-02-10 18:17:08Z romanb $
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the LGPL. For more information, see
  19.  * <http://www.phpdoctrine.com>.
  20.  */
  21. Doctrine::autoload('Doctrine_Connection_Exception');
  22. /**
  23.  * Doctrine_Connection_Mysql_Exception
  24.  *
  25.  * @package     Doctrine
  26.  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  27.  * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
  28.  * @author      Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
  29.  * @since       1.0
  30.  * @version     $Revision: 1080 $
  31.  * @category    Object Relational Mapping
  32.  * @link        www.phpdoctrine.com
  33.  */
  34. {
  35.     /**
  36.      * @var array $errorCodeMap         an array that is used for determining portable
  37.      *                                   error code from a native database error code
  38.      */
  39.     protected static $errorCodeMap array(
  40.                                       1004 => Doctrine::ERR_CANNOT_CREATE,
  41.                                       1005 => Doctrine::ERR_CANNOT_CREATE,
  42.                                       1006 => Doctrine::ERR_CANNOT_CREATE,
  43.                                       1007 => Doctrine::ERR_ALREADY_EXISTS,
  44.                                       1008 => Doctrine::ERR_CANNOT_DROP,
  45.                                       1022 => Doctrine::ERR_ALREADY_EXISTS,
  46.                                       1044 => Doctrine::ERR_ACCESS_VIOLATION,
  47.                                       1046 => Doctrine::ERR_NODBSELECTED,
  48.                                       1048 => Doctrine::ERR_CONSTRAINT,
  49.                                       1049 => Doctrine::ERR_NOSUCHDB,
  50.                                       1050 => Doctrine::ERR_ALREADY_EXISTS,
  51.                                       1051 => Doctrine::ERR_NOSUCHTABLE,
  52.                                       1054 => Doctrine::ERR_NOSUCHFIELD,
  53.                                       1061 => Doctrine::ERR_ALREADY_EXISTS,
  54.                                       1062 => Doctrine::ERR_ALREADY_EXISTS,
  55.                                       1064 => Doctrine::ERR_SYNTAX,
  56.                                       1091 => Doctrine::ERR_NOT_FOUND,
  57.                                       1100 => Doctrine::ERR_NOT_LOCKED,
  58.                                       1136 => Doctrine::ERR_VALUE_COUNT_ON_ROW,
  59.                                       1142 => Doctrine::ERR_ACCESS_VIOLATION,
  60.                                       1146 => Doctrine::ERR_NOSUCHTABLE,
  61.                                       1216 => Doctrine::ERR_CONSTRAINT,
  62.                                       1217 => Doctrine::ERR_CONSTRAINT,
  63.                                       );
  64.     /**
  65.      * This method checks if native error code/message can be
  66.      * converted into a portable code and then adds this
  67.      * portable error code to $portableCode field
  68.      *
  69.      * @param array $errorInfo      error info array
  70.      * @since 1.0
  71.      * @return boolean              whether or not the error info processing was successfull
  72.      *                               (the process is successfull if portable error code was found)
  73.      */
  74.     public function processErrorInfo(array $errorInfo)
  75.     {
  76.         $code $errorInfo[1];
  77.         if (isset(self::$errorCodeMap[$code])) {
  78.             $this->portableCode = self::$errorCodeMap[$code];
  79.             return true;
  80.         }
  81.         return false;
  82.     }
  83. }