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