diff options
-rw-r--r-- | ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp | 26 | ||||
-rw-r--r-- | ext/intl/tests/breakiter___construct_error.phpt | 5 | ||||
-rw-r--r-- | ext/intl/tests/rbbiter___construct_basic.phpt | 6 |
3 files changed, 17 insertions, 20 deletions
diff --git a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp index 67fb2b502e..476873330d 100644 --- a/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp +++ b/ext/intl/breakiterator/rulebasedbreakiterator_methods.cpp @@ -52,33 +52,33 @@ static void _php_intlrbbi_constructor_body(INTERNAL_FUNCTION_PARAMETERS) UParseError parseError = UParseError(); if (intl_stringFromChar(rulesStr, rules, rules_len, &status) == FAILURE) { - intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, - "rbbi_create_instance: rules were not a valid UTF-8 string", - 0); - RETURN_NULL(); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "rules were not a valid UTF-8 string", 0); + RETURN_THROWS(); } rbbi = new RuleBasedBreakIterator(rulesStr, parseError, status); intl_error_set_code(NULL, status); if (U_FAILURE(status)) { - char *msg; smart_str parse_error_str; parse_error_str = intl_parse_error_to_string(&parseError); - spprintf(&msg, 0, "rbbi_create_instance: unable to create " - "RuleBasedBreakIterator from rules (%s)", parse_error_str.s? ZSTR_VAL(parse_error_str.s) : ""); + zend_throw_exception_ex(IntlException_ce_ptr, 0, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create RuleBasedBreakIterator from rules (%s)", + parse_error_str.s ? ZSTR_VAL(parse_error_str.s) : ""); smart_str_free(&parse_error_str); - intl_error_set_custom_msg(NULL, msg, 1); - efree(msg); delete rbbi; - return; + RETURN_THROWS(); } } else { // compiled rbbi = new RuleBasedBreakIterator((uint8_t*)rules, rules_len, status); if (U_FAILURE(status)) { - intl_error_set(NULL, status, "rbbi_create_instance: unable to " - "create instance from compiled rules", 0); + zend_throw_exception(IntlException_ce_ptr, + "IntlRuleBasedBreakIterator::__construct(): " + "unable to create instance from compiled rules", 0); delete rbbi; - return; + RETURN_THROWS(); } } diff --git a/ext/intl/tests/breakiter___construct_error.phpt b/ext/intl/tests/breakiter___construct_error.phpt index a18d8d5a5d..57952766ec 100644 --- a/ext/intl/tests/breakiter___construct_error.phpt +++ b/ext/intl/tests/breakiter___construct_error.phpt @@ -4,7 +4,6 @@ IntlRuleBasedBreakIterator::__construct(): arg errors <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> --FILE-- <?php -ini_set("intl.error_level", E_WARNING); function print_exception($e) { echo "\nException: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . "\n"; @@ -38,7 +37,7 @@ try { } ?> --EXPECTF-- -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create RuleBasedBreakIterator from rules (parse error on line 1, offset 31) in %s on line %d Exception: IntlRuleBasedBreakIterator::__construct() expects at least 1 parameter, 0 given in %s on line %d @@ -46,4 +45,4 @@ Exception: IntlRuleBasedBreakIterator::__construct() expects at most 2 parameter Exception: IntlRuleBasedBreakIterator::__construct(): Argument #2 ($areCompiled) must be of type bool, array given in %s on line %d -Exception: IntlRuleBasedBreakIterator::__construct(): rbbi_create_instance: unable to create instance from compiled rules in %s on line %d +Exception: IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules in %s on line %d diff --git a/ext/intl/tests/rbbiter___construct_basic.phpt b/ext/intl/tests/rbbiter___construct_basic.phpt index 9f20806fa5..def14d25da 100644 --- a/ext/intl/tests/rbbiter___construct_basic.phpt +++ b/ext/intl/tests/rbbiter___construct_basic.phpt @@ -6,7 +6,6 @@ if (!extension_loaded('intl')) die('skip intl extension not enabled'); --FILE-- <?php -ini_set("intl.error_level", E_WARNING); ini_set("intl.default_locale", "pt_PT"); $rules = <<<RULES @@ -28,11 +27,10 @@ var_dump(get_class($rbbi)); try { $obj = new IntlRuleBasedBreakIterator('[\p{Letter}\uFFFD]+;[:number:]+', 'aoeu'); } catch (IntlException $e) { - var_dump(intl_get_error_code(), intl_get_error_message()); + echo $e->getMessage(), "\n"; } ?> --EXPECT-- string(26) "IntlRuleBasedBreakIterator" -int(1) -string(93) "rbbi_create_instance: unable to create instance from compiled rules: U_ILLEGAL_ARGUMENT_ERROR" +IntlRuleBasedBreakIterator::__construct(): unable to create instance from compiled rules |