diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-03-30 12:14:43 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-03-30 12:14:43 +0300 |
commit | 9155a267adeeb6f442f97892de441e4b6666ce73 (patch) | |
tree | 7d525ab7379401c38b4416886655b4753ec5701a /ext/intl/intl_error.c | |
parent | c71c97e101f239d487c7a9797bdf193098d469ca (diff) | |
parent | 910a3243063f0490a60e5c3c0e1467a6171f4e39 (diff) | |
download | php-git-9155a267adeeb6f442f97892de441e4b6666ce73.tar.gz |
Merge branch 'InternalClassClean' of github.com:Danack/php-src into InternalClassClean
* 'InternalClassClean' of github.com:Danack/php-src:
Fixed indentation. Fixed comment style. Fixed commented out code.
Reverted change to function name and added note of why it is different from the class it is actually changing.
Made UConverter throw an exception if the constructor fails.
Fixed PDO constructor to not return null.
Fixed fileinfo behaviour.
Made Phar throw exception on bad constructor.
Converted intl extension to use IntlException in constructors.
Fixed SplFixedArray and tests.
Fixed ReflectionExtension and ReflectionProperty.
Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter.
Fixed PDORow behaviour and message.
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 ) |