From 10324891f81ffa155cd563c3a21bebdafc47ad3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Andr=C3=A9=20dos=20Santos=20Lopes?= Date: Sun, 8 Jan 2012 18:41:53 +0000 Subject: - Added the ability for the intl exception to throw exceptions when a global error is set. --- ext/intl/intl_error.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'ext/intl/intl_error.c') diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 9c2e13dfd5..2c7066b081 100755 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -21,12 +21,15 @@ #endif #include +#include #include "php_intl.h" #include "intl_error.h" ZEND_EXTERN_MODULE_GLOBALS( intl ) +static zend_class_entry *IntlException_ce_ptr; + /* {{{ intl_error* intl_g_error_get() * Return global error structure. */ @@ -102,8 +105,11 @@ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg TSRMLS_D if( !msg ) return; - if(!err && INTL_G(error_level)) { - php_error_docref(NULL TSRMLS_CC, INTL_G(error_level), "%s", msg); + if( !err ) { + if( INTL_G( error_level ) ) + php_error_docref( NULL TSRMLS_CC, INTL_G( error_level ), "%s", msg ); + if( INTL_G( use_exceptions ) ) + zend_throw_exception_ex( IntlException_ce_ptr, 0 TSRMLS_CC, "%s", msg ); } if( !err && !( err = intl_g_error_get( TSRMLS_C ) ) ) return; @@ -223,6 +229,21 @@ void intl_errors_set_code( intl_error* err, UErrorCode err_code TSRMLS_DC ) } /* }}} */ +void intl_register_IntlException_class( TSRMLS_D ) +{ + zend_class_entry ce, + *default_exception_ce; + + default_exception_ce = zend_exception_get_default( TSRMLS_C ); + + /* Create and register 'IntlException' class. */ + INIT_CLASS_ENTRY_EX( ce, "IntlException", sizeof( "IntlException" ) - 1, NULL ); + IntlException_ce_ptr = zend_register_internal_class_ex( &ce, + default_exception_ce, NULL TSRMLS_CC ); + IntlException_ce_ptr->create_object = default_exception_ce->create_object; +} +/* }}} */ + /* * Local variables: * tab-width: 4 -- cgit v1.2.1