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  Exception
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_Exception extends Exception
34
{
35
    /**
36
     * @var array $_errorMessages       an array of error messages
37
     */
38
    protected static $_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
     * Return a textual error message for a Doctrine error code
75
     *
76
     * @param   int|array   integer error code,
77
     *                           null to get the current error code-message map,
78
     *                           or an array with a new error code-message map
79
     *
80
     * @return  string  error message
81
     */
82
    public function errorMessage($value = null)
83
    {
84
        if (is_null($value)) {
85
            return self::$_errorMessages;
86
        }
87
 
88
        return isset(self::$_errorMessages[$value]) ?
89
           self::$_errorMessages[$value] : self::$_errorMessages[Doctrine_Core::ERR];
90
    }
91
 
92
}