PageRenderTime 40ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/bluebox/libraries/doctrine/lib/Doctrine/Connection/Exception.php

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