# Source for file Exception.php

Documentation is available at Exception.php

1. <?php
2. /*
3. * $Id: Exception.php 1080 2007-02-10 18:17:08Z romanb $
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.com>.
20. */
21. Doctrine::autoload('Doctrine_Connection_Exception');
22. /**
23. * Doctrine_Connection_Mssql_Exception
24. *
25. * @package Doctrine
26. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
27. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
28. * @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
29. * @since 1.0
30. * @version $Revision: 1080 $
31. * @category Object Relational Mapping
32. * @link www.phpdoctrine.com
33. */
34. class Doctrine_Connection_Mssql_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. 110 => Doctrine::ERR_VALUE_COUNT_ON_ROW,
42. 155 => Doctrine::ERR_NOSUCHFIELD,
43. 170 => Doctrine::ERR_SYNTAX,
44. 207 => Doctrine::ERR_NOSUCHFIELD,
45. 208 => Doctrine::ERR_NOSUCHTABLE,
46. 245 => Doctrine::ERR_INVALID_NUMBER,
47. 515 => Doctrine::ERR_CONSTRAINT_NOT_NULL,
48. 547 => Doctrine::ERR_CONSTRAINT,
49. 1913 => Doctrine::ERR_ALREADY_EXISTS,
50. 2627 => Doctrine::ERR_CONSTRAINT,
51. 2714 => Doctrine::ERR_ALREADY_EXISTS,
52. 3701 => Doctrine::ERR_NOSUCHTABLE,
53. 8134 => Doctrine::ERR_DIVZERO,
54. );
55. /**
56. * This method checks if native error code/message can be
57. * converted into a portable code and then adds this
58. * portable error code to $portableCode field
59. *
60. * @param array $errorInfo error info array
61. * @since 1.0
62. * @return boolean whether or not the error info processing was successfull
63. * (the process is successfull if portable error code was found)
64. */
65. public function processErrorInfo(array $errorInfo)
66. {
67. $code = $errorInfo[1];
68. if (isset(self::$errorCodeMap[$code])) {
69. $this->portableCode = self::$errorCodeMap[$code];
70. return true;
71. }
72. return false;
73. }
74. }