# Coverage for Doctrine_Connection_Exception

Back to coverage report

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_Exception');
22 | /**
23 | * Doctrine_Exception
24 | *
25 | * @package Doctrine
26 | * @subpackage Connection
27 | * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
28 | * @link www.phpdoctrine.org
29 | * @since 1.0
30 | * @version $Revision: 2963 $
31 | * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
32 | */
33 | class Doctrine_Connection_Exception extends Doctrine_Exception
34 | {
35 | /**
36 | * @var array $errorMessages an array containing messages for portable error codes
37 | */
38 | static protected $errorMessages = array(
39 | Doctrine::ERR => 'unknown error',
40 | Doctrine::ERR_ALREADY_EXISTS => 'already exists',
41 | Doctrine::ERR_CANNOT_CREATE => 'can not create',
42 | Doctrine::ERR_CANNOT_ALTER => 'can not alter',
43 | Doctrine::ERR_CANNOT_REPLACE => 'can not replace',
44 | Doctrine::ERR_CANNOT_DELETE => 'can not delete',
45 | Doctrine::ERR_CANNOT_DROP => 'can not drop',
46 | Doctrine::ERR_CONSTRAINT => 'constraint violation',
47 | Doctrine::ERR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint',
48 | Doctrine::ERR_DIVZERO => 'division by zero',
49 | Doctrine::ERR_INVALID => 'invalid',
50 | Doctrine::ERR_INVALID_DATE => 'invalid date or time',
51 | Doctrine::ERR_INVALID_NUMBER => 'invalid number',
52 | Doctrine::ERR_MISMATCH => 'mismatch',
53 | Doctrine::ERR_NODBSELECTED => 'no database selected',
54 | Doctrine::ERR_NOSUCHFIELD => 'no such field',
55 | Doctrine::ERR_NOSUCHTABLE => 'no such table',
56 | Doctrine::ERR_NOT_CAPABLE => 'Doctrine backend not capable',
57 | Doctrine::ERR_NOT_FOUND => 'not found',
58 | Doctrine::ERR_NOT_LOCKED => 'not locked',
59 | Doctrine::ERR_SYNTAX => 'syntax error',
60 | Doctrine::ERR_UNSUPPORTED => 'not supported',
61 | Doctrine::ERR_VALUE_COUNT_ON_ROW => 'value count on row',
62 | Doctrine::ERR_INVALID_DSN => 'invalid DSN',
63 | Doctrine::ERR_CONNECT_FAILED => 'connect failed',
64 | Doctrine::ERR_NEED_MORE_DATA => 'insufficient data supplied',
65 | Doctrine::ERR_EXTENSION_NOT_FOUND=> 'extension not found',
66 | Doctrine::ERR_NOSUCHDB => 'no such database',
67 | Doctrine::ERR_ACCESS_VIOLATION => 'insufficient permissions',
68 | Doctrine::ERR_LOADMODULE => 'error while including on demand module',
69 | Doctrine::ERR_TRUNCATED => 'truncated',
70 | Doctrine::ERR_DEADLOCK => 'deadlock detected',
71 | );
72 |
73 | /**
74 | * @see Doctrine::ERR_* constants
75 | * @since 1.0
76 | * @var integer $portableCode portable error code
77 | */
78 | protected $portableCode;
79 |
80 | /**
81 | * getPortableCode
82 | * returns portable error code
83 | *
84 | * @return integer portable error code
85 | */
86 | public function getPortableCode()
87 | {
88 | return $this->portableCode;
89 | }
90 |
91 | /**
92 | * getPortableMessage
93 | * returns portable error message
94 | *
95 | * @return string portable error message
96 | */
97 | public function getPortableMessage()
98 | {
99 | return self::errorMessage($this->portableCode);
100 | }
101 |
102 | /**
103 | * Return a textual error message for a Doctrine error code
104 | *
105 | * @param int|array integer error code,
106 | * null to get the current error code-message map,
107 | * or an array with a new error code-message map
108 | *
109 | * @return string error message, or false if the error code was
110 | * not recognized
111 | */
112 | public function errorMessage($value = null)
113 | {
114 | return isset(self::$errorMessages[$value]) ?
115 | self::$errorMessages[$value] : self::$errorMessages[Doctrine::ERR];
116 | }
117 | }