Back to index

php5  5.3.10
domexception.c
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Christian Stocker <chregu@php.net>                          |
00016    |          Rob Richards <rrichards@php.net>                            |
00017    +----------------------------------------------------------------------+
00018 */
00019 
00020 /* $Id: domexception.c 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #include "config.h"
00024 #endif
00025 
00026 #include "php.h"
00027 #if HAVE_LIBXML && HAVE_DOM
00028 #include "php_dom.h"
00029 
00030 /*
00031 * class DOMException 
00032 *
00033 * URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-17189187
00034 * Since: 
00035 */
00036 
00037 extern zend_class_entry *dom_domexception_class_entry;
00038 
00039 const zend_function_entry php_dom_domexception_class_functions[] = {
00040        PHP_FE_END
00041 };
00042 
00043 void php_dom_throw_error_with_message(int error_code, char *error_message, int strict_error TSRMLS_DC) /* {{{ */
00044 {
00045        if (strict_error == 1) {
00046               zend_throw_exception(dom_domexception_class_entry, error_message, error_code TSRMLS_CC);
00047        } else {
00048               php_libxml_issue_error(E_WARNING, error_message TSRMLS_CC);
00049        }
00050 }
00051 /* }}} */
00052 
00053 /* {{{ php_dom_throw_error */
00054 void php_dom_throw_error(int error_code, int strict_error TSRMLS_DC)
00055 {
00056        char *error_message;
00057 
00058        switch (error_code)
00059        {
00060               case INDEX_SIZE_ERR:
00061                      error_message = "Index Size Error";
00062                      break;
00063               case DOMSTRING_SIZE_ERR:
00064                      error_message = "DOM String Size Error";
00065                      break;
00066               case HIERARCHY_REQUEST_ERR:
00067                      error_message = "Hierarchy Request Error";
00068                      break;
00069               case WRONG_DOCUMENT_ERR:
00070                      error_message = "Wrong Document Error";
00071                      break;
00072               case INVALID_CHARACTER_ERR:
00073                      error_message = "Invalid Character Error";
00074                      break;
00075               case NO_DATA_ALLOWED_ERR:
00076                      error_message = "No Data Allowed Error";
00077                      break;
00078               case NO_MODIFICATION_ALLOWED_ERR:
00079                      error_message = "No Modification Allowed Error";
00080                      break;
00081               case NOT_FOUND_ERR:
00082                      error_message = "Not Found Error";
00083                      break;
00084               case NOT_SUPPORTED_ERR:
00085                      error_message = "Not Supported Error";
00086                      break;
00087               case INUSE_ATTRIBUTE_ERR:
00088                      error_message = "Inuse Attribute Error";
00089                      break;
00090               case INVALID_STATE_ERR:
00091                      error_message = "Invalid State Error";
00092                      break;
00093               case SYNTAX_ERR:
00094                      error_message = "Syntax Error";
00095                      break;
00096               case INVALID_MODIFICATION_ERR:
00097                      error_message = "Invalid Modification Error";
00098                      break;
00099               case NAMESPACE_ERR:
00100                      error_message = "Namespace Error";
00101                      break;
00102               case INVALID_ACCESS_ERR:
00103                      error_message = "Invalid Access Error";
00104                      break;
00105               case VALIDATION_ERR:
00106                      error_message = "Validation Error";
00107                      break;
00108               default:
00109                      error_message = "Unhandled Error";
00110        }
00111 
00112        php_dom_throw_error_with_message(error_code, error_message, strict_error TSRMLS_CC);
00113 }
00114 /* }}} end php_dom_throw_error */
00115 
00116 #endif /* HAVE_LIBXML && HAVE_DOM */
00117 
00118 /*
00119  * Local variables:
00120  * tab-width: 4
00121  * c-basic-offset: 4
00122  * End:
00123  * vim600: noet sw=4 ts=4 fdm=marker
00124  * vim<600: noet sw=4 ts=4
00125  */