1 : /*
2 : +----------------------------------------------------------------------+
3 : | PHP Version 6 |
4 : +----------------------------------------------------------------------+
5 : | Copyright (c) 1997-2009 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 :
20 : /* $Id: domexception.c 276986 2009-03-10 23:40:06Z helly $ */
21 :
22 : #ifdef HAVE_CONFIG_H
23 : #include "config.h"
24 : #endif
25 :
26 : #include "php.h"
27 : #if HAVE_LIBXML && HAVE_DOM
28 : #include "php_dom.h"
29 :
30 : /*
31 : * class DOMException
32 : *
33 : * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-17189187
34 : * Since:
35 : */
36 :
37 : extern zend_class_entry *dom_domexception_class_entry;
38 :
39 : const zend_function_entry php_dom_domexception_class_functions[] = {
40 : {NULL, NULL, NULL}
41 : };
42 :
43 : void php_dom_throw_error_with_message(int error_code, char *error_message, int strict_error TSRMLS_DC) /* {{{ */
44 50 : {
45 50 : if (strict_error == 1) {
46 41 : zend_throw_exception(dom_domexception_class_entry, error_message, error_code TSRMLS_CC);
47 : } else {
48 9 : php_libxml_issue_error(E_WARNING, error_message TSRMLS_CC);
49 : }
50 50 : }
51 : /* }}} */
52 :
53 : /* {{{ php_dom_throw_error */
54 : void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC)
55 50 : {
56 : char *error_message;
57 :
58 50 : switch (error_code)
59 : {
60 : case INDEX_SIZE_ERR:
61 5 : error_message = "Index Size Error";
62 5 : break;
63 : case DOMSTRING_SIZE_ERR:
64 0 : error_message = "DOM String Size Error";
65 0 : break;
66 : case HIERARCHY_REQUEST_ERR:
67 2 : error_message = "Hierarchy Request Error";
68 2 : break;
69 : case WRONG_DOCUMENT_ERR:
70 1 : error_message = "Wrong Document Error";
71 1 : break;
72 : case INVALID_CHARACTER_ERR:
73 14 : error_message = "Invalid Character Error";
74 14 : break;
75 : case NO_DATA_ALLOWED_ERR:
76 0 : error_message = "No Data Allowed Error";
77 0 : break;
78 : case NO_MODIFICATION_ALLOWED_ERR:
79 2 : error_message = "No Modification Allowed Error";
80 2 : break;
81 : case NOT_FOUND_ERR:
82 0 : error_message = "Not Found Error";
83 0 : break;
84 : case NOT_SUPPORTED_ERR:
85 0 : error_message = "Not Supported Error";
86 0 : break;
87 : case INUSE_ATTRIBUTE_ERR:
88 0 : error_message = "Inuse Attribute Error";
89 0 : break;
90 : case INVALID_STATE_ERR:
91 8 : error_message = "Invalid State Error";
92 8 : break;
93 : case SYNTAX_ERR:
94 0 : error_message = "Syntax Error";
95 0 : break;
96 : case INVALID_MODIFICATION_ERR:
97 0 : error_message = "Invalid Modification Error";
98 0 : break;
99 : case NAMESPACE_ERR:
100 18 : error_message = "Namespace Error";
101 18 : break;
102 : case INVALID_ACCESS_ERR:
103 0 : error_message = "Invalid Access Error";
104 0 : break;
105 : case VALIDATION_ERR:
106 0 : error_message = "Validation Error";
107 0 : break;
108 : default:
109 0 : error_message = "Unhandled Error";
110 : }
111 :
112 50 : php_dom_throw_error_with_message(error_code, error_message, strict_error TSRMLS_CC);
113 50 : }
114 : /* }}} end php_dom_throw_error */
115 :
116 : #endif /* HAVE_LIBXML && HAVE_DOM */
117 :
118 : /*
119 : * Local variables:
120 : * tab-width: 4
121 : * c-basic-offset: 4
122 : * End:
123 : * vim600: noet sw=4 ts=4 fdm=marker
124 : * vim<600: noet sw=4 ts=4
125 : */
|