Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/*
3
 *  $Id: Exception.php 7490 2010-03-29 19:53:27Z jwage $
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.doctrine-project.org>.
20
 */
21
 
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.doctrine-project.org
29
 * @since       1.0
30
 * @version     $Revision: 7490 $
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_Core::ERR                    => 'unknown error',
40
                Doctrine_Core::ERR_ALREADY_EXISTS     => 'already exists',
41
                Doctrine_Core::ERR_CANNOT_CREATE      => 'can not create',
42
                Doctrine_Core::ERR_CANNOT_ALTER       => 'can not alter',
43
                Doctrine_Core::ERR_CANNOT_REPLACE     => 'can not replace',
44
                Doctrine_Core::ERR_CANNOT_DELETE      => 'can not delete',
45
                Doctrine_Core::ERR_CANNOT_DROP        => 'can not drop',
46
                Doctrine_Core::ERR_CONSTRAINT         => 'constraint violation',
47
                Doctrine_Core::ERR_CONSTRAINT_NOT_NULL=> 'null value violates not-null constraint',
48
                Doctrine_Core::ERR_DIVZERO            => 'division by zero',
49
                Doctrine_Core::ERR_INVALID            => 'invalid',
50
                Doctrine_Core::ERR_INVALID_DATE       => 'invalid date or time',
51
                Doctrine_Core::ERR_INVALID_NUMBER     => 'invalid number',
52
                Doctrine_Core::ERR_MISMATCH           => 'mismatch',
53
                Doctrine_Core::ERR_NODBSELECTED       => 'no database selected',
54
                Doctrine_Core::ERR_NOSUCHFIELD        => 'no such field',
55
                Doctrine_Core::ERR_NOSUCHTABLE        => 'no such table',
56
                Doctrine_Core::ERR_NOT_CAPABLE        => 'Doctrine backend not capable',
57
                Doctrine_Core::ERR_NOT_FOUND          => 'not found',
58
                Doctrine_Core::ERR_NOT_LOCKED         => 'not locked',
59
                Doctrine_Core::ERR_SYNTAX             => 'syntax error',
60
                Doctrine_Core::ERR_UNSUPPORTED        => 'not supported',
61
                Doctrine_Core::ERR_VALUE_COUNT_ON_ROW => 'value count on row',
62
                Doctrine_Core::ERR_INVALID_DSN        => 'invalid DSN',
63
                Doctrine_Core::ERR_CONNECT_FAILED     => 'connect failed',
64
                Doctrine_Core::ERR_NEED_MORE_DATA     => 'insufficient data supplied',
65
                Doctrine_Core::ERR_EXTENSION_NOT_FOUND=> 'extension not found',
66
                Doctrine_Core::ERR_NOSUCHDB           => 'no such database',
67
                Doctrine_Core::ERR_ACCESS_VIOLATION   => 'insufficient permissions',
68
                Doctrine_Core::ERR_LOADMODULE         => 'error while including on demand module',
69
                Doctrine_Core::ERR_TRUNCATED          => 'truncated',
70
                Doctrine_Core::ERR_DEADLOCK           => 'deadlock detected',
71
                );
72
 
73
    /**
74
     * @see Doctrine_Core::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_Core::ERR];
116
    }
117
 
118
    /**
119
     * This method checks if native error code/message can be
120
     * converted into a portable code and then adds this
121
     * portable error code to $portableCode field
122
     *
123
     * @param array $errorInfo      error info array
124
     * @since 1.0
125
     * @return boolean              whether or not the error info processing was successfull
126
     *                              (the process is successfull if portable error code was found)
127
     */
128
    public function processErrorInfo(array $errorInfo)
129
    { }
130
}