domexception.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Christian Stocker <chregu@php.net> |
  16. | Rob Richards <rrichards@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. /* $Id$ */
  20. #ifdef HAVE_CONFIG_H
  21. #include "config.h"
  22. #endif
  23. #include "php.h"
  24. #if HAVE_LIBXML && HAVE_DOM
  25. #include "php_dom.h"
  26. /*
  27. * class DOMException
  28. *
  29. * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-17189187
  30. * Since:
  31. */
  32. extern zend_class_entry *dom_domexception_class_entry;
  33. const zend_function_entry php_dom_domexception_class_functions[] = {
  34. PHP_FE_END
  35. };
  36. void php_dom_throw_error_with_message(int error_code, char *error_message, int strict_error TSRMLS_DC) /* {{{ */
  37. {
  38. if (strict_error == 1) {
  39. zend_throw_exception(dom_domexception_class_entry, error_message, error_code TSRMLS_CC);
  40. } else {
  41. php_libxml_issue_error(E_WARNING, error_message TSRMLS_CC);
  42. }
  43. }
  44. /* }}} */
  45. /* {{{ php_dom_throw_error */
  46. void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC)
  47. {
  48. char *error_message;
  49. switch (error_code)
  50. {
  51. case INDEX_SIZE_ERR:
  52. error_message = "Index Size Error";
  53. break;
  54. case DOMSTRING_SIZE_ERR:
  55. error_message = "DOM String Size Error";
  56. break;
  57. case HIERARCHY_REQUEST_ERR:
  58. error_message = "Hierarchy Request Error";
  59. break;
  60. case WRONG_DOCUMENT_ERR:
  61. error_message = "Wrong Document Error";
  62. break;
  63. case INVALID_CHARACTER_ERR:
  64. error_message = "Invalid Character Error";
  65. break;
  66. case NO_DATA_ALLOWED_ERR:
  67. error_message = "No Data Allowed Error";
  68. break;
  69. case NO_MODIFICATION_ALLOWED_ERR:
  70. error_message = "No Modification Allowed Error";
  71. break;
  72. case NOT_FOUND_ERR:
  73. error_message = "Not Found Error";
  74. break;
  75. case NOT_SUPPORTED_ERR:
  76. error_message = "Not Supported Error";
  77. break;
  78. case INUSE_ATTRIBUTE_ERR:
  79. error_message = "Inuse Attribute Error";
  80. break;
  81. case INVALID_STATE_ERR:
  82. error_message = "Invalid State Error";
  83. break;
  84. case SYNTAX_ERR:
  85. error_message = "Syntax Error";
  86. break;
  87. case INVALID_MODIFICATION_ERR:
  88. error_message = "Invalid Modification Error";
  89. break;
  90. case NAMESPACE_ERR:
  91. error_message = "Namespace Error";
  92. break;
  93. case INVALID_ACCESS_ERR:
  94. error_message = "Invalid Access Error";
  95. break;
  96. case VALIDATION_ERR:
  97. error_message = "Validation Error";
  98. break;
  99. default:
  100. error_message = "Unhandled Error";
  101. }
  102. php_dom_throw_error_with_message(error_code, error_message, strict_error TSRMLS_CC);
  103. }
  104. /* }}} end php_dom_throw_error */
  105. #endif /* HAVE_LIBXML && HAVE_DOM */
  106. /*
  107. * Local variables:
  108. * tab-width: 4
  109. * c-basic-offset: 4
  110. * End:
  111. * vim600: noet sw=4 ts=4 fdm=marker
  112. * vim<600: noet sw=4 ts=4
  113. */