summaryrefslogtreecommitdiff
path: root/ext/intl/intl_error.c
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2012-01-08 18:41:53 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2012-01-08 18:41:53 +0000
commit10324891f81ffa155cd563c3a21bebdafc47ad3d (patch)
tree535a604872bd9785f6a2b4b92d636f4f1d965cb1 /ext/intl/intl_error.c
parent2651a1fc39813533e8aa6e6afe163d8126c685ca (diff)
downloadphp-git-10324891f81ffa155cd563c3a21bebdafc47ad3d.tar.gz
- Added the ability for the intl exception to throw exceptions when a global error is set.
Diffstat (limited to 'ext/intl/intl_error.c')
-rwxr-xr-xext/intl/intl_error.c25
1 files changed, 23 insertions, 2 deletions
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 <php.h>
+#include <zend_exceptions.h>
#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