1 : /*
2 : +----------------------------------------------------------------------+
3 : | PHP Version 5 |
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 272374 2008-12-31 11:17:49Z sebastian $ */
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 : /*
32 : * class DOMException
33 : *
34 : * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-17189187
35 : * Since:
36 : */
37 :
38 : extern zend_class_entry *dom_domexception_class_entry;
39 :
40 : zend_function_entry php_dom_domexception_class_functions[] = {
41 : {NULL, NULL, NULL}
42 : };
43 :
44 : /* {{{ php_dom_throw_error_with_message */
45 : void php_dom_throw_error_with_message(int error_code, char *error_message, int strict_error TSRMLS_DC)
46 45 : {
47 45 : if (strict_error == 1) {
48 36 : zend_throw_exception(dom_domexception_class_entry, error_message, error_code TSRMLS_CC);
49 : } else {
50 9 : php_libxml_issue_error(E_WARNING, error_message TSRMLS_CC);
51 : }
52 45 : }
53 :
54 : /* {{{ php_dom_throw_error */
55 : void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC)
56 45 : {
57 : char *error_message;
58 :
59 45 : switch (error_code)
60 : {
61 : case INDEX_SIZE_ERR:
62 5 : error_message = "Index Size Error";
63 5 : break;
64 : case DOMSTRING_SIZE_ERR:
65 0 : error_message = "DOM String Size Error";
66 0 : break;
67 : case HIERARCHY_REQUEST_ERR:
68 2 : error_message = "Hierarchy Request Error";
69 2 : break;
70 : case WRONG_DOCUMENT_ERR:
71 1 : error_message = "Wrong Document Error";
72 1 : break;
73 : case INVALID_CHARACTER_ERR:
74 11 : error_message = "Invalid Character Error";
75 11 : break;
76 : case NO_DATA_ALLOWED_ERR:
77 0 : error_message = "No Data Allowed Error";
78 0 : break;
79 : case NO_MODIFICATION_ALLOWED_ERR:
80 1 : error_message = "No Modification Allowed Error";
81 1 : break;
82 : case NOT_FOUND_ERR:
83 0 : error_message = "Not Found Error";
84 0 : break;
85 : case NOT_SUPPORTED_ERR:
86 0 : error_message = "Not Supported Error";
87 0 : break;
88 : case INUSE_ATTRIBUTE_ERR:
89 0 : error_message = "Inuse Attribute Error";
90 0 : break;
91 : case INVALID_STATE_ERR:
92 8 : error_message = "Invalid State Error";
93 8 : break;
94 : case SYNTAX_ERR:
95 0 : error_message = "Syntax Error";
96 0 : break;
97 : case INVALID_MODIFICATION_ERR:
98 0 : error_message = "Invalid Modification Error";
99 0 : break;
100 : case NAMESPACE_ERR:
101 17 : error_message = "Namespace Error";
102 17 : break;
103 : case INVALID_ACCESS_ERR:
104 0 : error_message = "Invalid Access Error";
105 0 : break;
106 : case VALIDATION_ERR:
107 0 : error_message = "Validation Error";
108 0 : break;
109 : default:
110 0 : error_message = "Unhandled Error";
111 : }
112 :
113 45 : php_dom_throw_error_with_message(error_code, error_message, strict_error TSRMLS_CC);
114 45 : }
115 : /* }}} end php_dom_throw_error */
116 :
117 : #endif /* HAVE_LIBXML && HAVE_DOM */
|