diff options
author | Danack <Danack@basereality.com> | 2015-03-15 13:59:48 +0000 |
---|---|---|
committer | Danack <Danack@basereality.com> | 2015-03-15 13:59:48 +0000 |
commit | 99dae96dc0041f856ae066b3f572495da609d28e (patch) | |
tree | fa5dbd0d839b4973359273103bd2cbfb90a9288e /ext/intl/intl_error.c | |
parent | c57bde7c9e2f4ac3e93f096eaa93d4ab0133915d (diff) | |
download | php-git-99dae96dc0041f856ae066b3f572495da609d28e.tar.gz |
Converted intl extension to use IntlException in constructors.
Diffstat (limited to 'ext/intl/intl_error.c')
-rw-r--r-- | ext/intl/intl_error.c | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/ext/intl/intl_error.c b/ext/intl/intl_error.c index 28a2a244e2..8ea5e7b4cf 100644 --- a/ext/intl/intl_error.c +++ b/ext/intl/intl_error.c @@ -29,7 +29,7 @@ ZEND_EXTERN_MODULE_GLOBALS( intl ) -static zend_class_entry *IntlException_ce_ptr; +zend_class_entry *IntlException_ce_ptr; /* {{{ intl_error* intl_g_error_get() * Return global error structure. @@ -103,14 +103,25 @@ void intl_error_reset( intl_error* err ) */ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg ) { + intl_error_set_custom_msg_ex( err, msg, copyMsg, 0 ); +} +/* }}} */ + + +/* {{{ void intl_error_set_custom_msg( intl_error* err, char* msg, int copyMsg ) + * Set last error message to msg copying it if needed. + */ +void intl_error_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException ) +{ if( !msg ) return; if( !err ) { - if( INTL_G( error_level ) ) - php_error_docref( NULL, INTL_G( error_level ), "%s", msg ); - if( INTL_G( use_exceptions ) ) + if ( forceException || INTL_G( use_exceptions ) ) { zend_throw_exception_ex( IntlException_ce_ptr, 0, "%s", msg ); + } else if( INTL_G( error_level ) ) { + php_error_docref( NULL, INTL_G( error_level ), "%s", msg ); + } } if( !err && !( err = intl_g_error_get( ) ) ) return; @@ -182,18 +193,38 @@ UErrorCode intl_error_get_code( intl_error* err ) */ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg ) { + intl_error_set_ex( err, code, msg, copyMsg, 0 ); +} +/* }}} */ + + +/* {{{ void intl_error_set( intl_error* err, UErrorCode code, char* msg, int copyMsg ) + * Set error code and message. + */ +void intl_error_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException ) +{ intl_error_set_code( err, code ); - intl_error_set_custom_msg( err, msg, copyMsg ); + intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException ); } /* }}} */ + /* {{{ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg ) * Set error code and message. */ void intl_errors_set( intl_error* err, UErrorCode code, char* msg, int copyMsg ) { + intl_errors_set_ex( err, code, msg, copyMsg, 0 ); +} +/* }}} */ + +/* {{{ void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg ) + * Set error code and message. + */ +void intl_errors_set_ex( intl_error* err, UErrorCode code, char* msg, int copyMsg, int forceException ) +{ intl_errors_set_code( err, code ); - intl_errors_set_custom_msg( err, msg, copyMsg ); + intl_errors_set_custom_msg_ex( err, msg, copyMsg, forceException ); } /* }}} */ @@ -212,13 +243,23 @@ void intl_errors_reset( intl_error* err ) */ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg ) { + intl_errors_set_custom_msg_ex( err, msg, copyMsg, 0 ); +} +/* }}} */ + + +/* {{{ void intl_errors_set_custom_msg( intl_error* err, char* msg, int copyMsg ) + */ +void intl_errors_set_custom_msg_ex( intl_error* err, char* msg, int copyMsg, int forceException ) +{ if(err) { - intl_error_set_custom_msg( err, msg, copyMsg ); + intl_error_set_custom_msg_ex( err, msg, copyMsg, forceException ); } - intl_error_set_custom_msg( NULL, msg, copyMsg ); + intl_error_set_custom_msg_ex( NULL, msg, copyMsg, forceException ); } /* }}} */ + /* {{{ intl_errors_set_code( intl_error* err, UErrorCode err_code ) */ void intl_errors_set_code( intl_error* err, UErrorCode err_code ) |