1 |
<?php
|
2 |
/*
|
3 |
* $Id: Exception.php 2963 2007-10-21 06:23:59Z Jonathan.Wage $
|
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.org>.
|
20 |
*/
|
21 |
Doctrine::autoload('Doctrine_Connection_Exception');
|
22 |
/**
|
23 |
* Doctrine_Connection_Oracle_Exception
|
24 |
*
|
25 |
* @package Doctrine
|
26 |
* @subpackage Connection
|
27 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
28 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
29 |
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
|
30 |
* @since 1.0
|
31 |
* @version $Revision: 2963 $
|
32 |
* @link www.phpdoctrine.org
|
33 |
*/
|
34 |
class Doctrine_Connection_Oracle_Exception extends Doctrine_Connection_Exception
|
35 |
{
|
36 |
/**
|
37 |
* @var array $errorCodeMap an array that is used for determining portable
|
38 |
* error code from a native database error code
|
39 |
*/
|
40 |
protected static $errorCodeMap = array(
|
41 |
1 => Doctrine::ERR_CONSTRAINT,
|
42 |
900 => Doctrine::ERR_SYNTAX,
|
43 |
904 => Doctrine::ERR_NOSUCHFIELD,
|
44 |
913 => Doctrine::ERR_VALUE_COUNT_ON_ROW,
|
45 |
921 => Doctrine::ERR_SYNTAX,
|
46 |
923 => Doctrine::ERR_SYNTAX,
|
47 |
942 => Doctrine::ERR_NOSUCHTABLE,
|
48 |
955 => Doctrine::ERR_ALREADY_EXISTS,
|
49 |
1400 => Doctrine::ERR_CONSTRAINT_NOT_NULL,
|
50 |
1401 => Doctrine::ERR_INVALID,
|
51 |
1407 => Doctrine::ERR_CONSTRAINT_NOT_NULL,
|
52 |
1418 => Doctrine::ERR_NOT_FOUND,
|
53 |
1476 => Doctrine::ERR_DIVZERO,
|
54 |
1722 => Doctrine::ERR_INVALID_NUMBER,
|
55 |
2289 => Doctrine::ERR_NOSUCHTABLE,
|
56 |
2291 => Doctrine::ERR_CONSTRAINT,
|
57 |
2292 => Doctrine::ERR_CONSTRAINT,
|
58 |
2449 => Doctrine::ERR_CONSTRAINT,
|
59 |
);
|
60 |
|
61 |
/**
|
62 |
* This method checks if native error code/message can be
|
63 |
* converted into a portable code and then adds this
|
64 |
* portable error code to $portableCode field
|
65 |
*
|
66 |
* @param array $errorInfo error info array
|
67 |
* @since 1.0
|
68 |
* @return boolean whether or not the error info processing was successfull
|
69 |
* (the process is successfull if portable error code was found)
|
70 |
*/
|
71 |
public function processErrorInfo(array $errorInfo)
|
72 |
{
|
73 |
$code = $errorInfo[1];
|
74 |
if (isset(self::$errorCodeMap[$code])) {
|
75 |
$this->portableCode = self::$errorCodeMap[$code];
|
76 |
return true;
|
77 |
}
|
78 |
return false;
|
79 |
}
|
80 |
} |