From: Sara Golemon Date: Sun, 25 Jun 2017 21:44:59 +0000 (-0400) Subject: Produce a better exception message when IntlDateFormatter constructor fails. X-Git-Tag: php-7.2.0alpha3~34^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecaf408d30af119c04c67bf99790655a1e818472;p=php Produce a better exception message when IntlDateFormatter constructor fails. --- diff --git a/ext/intl/dateformat/dateformat_create.cpp b/ext/intl/dateformat/dateformat_create.cpp index 00a5cc593c..e060711ce6 100644 --- a/ext/intl/dateformat/dateformat_create.cpp +++ b/ext/intl/dateformat/dateformat_create.cpp @@ -216,7 +216,7 @@ U_CFUNC PHP_METHOD( IntlDateFormatter, __construct ) return_value = getThis(); if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1) == FAILURE) { if (!EG(exception)) { - zend_throw_exception(IntlException_ce_ptr, "Constructor failed", 0); + zend_throw_exception(IntlException_ce_ptr, ZSTR_VAL(intl_error_get_message(NULL)), intl_error_get_code(NULL)); } } zend_restore_error_handling(&error_handling); diff --git a/ext/intl/tests/dateformat_invalid_timezone.phpt b/ext/intl/tests/dateformat_invalid_timezone.phpt new file mode 100644 index 0000000000..5b54fa89bb --- /dev/null +++ b/ext/intl/tests/dateformat_invalid_timezone.phpt @@ -0,0 +1,18 @@ +--TEST-- +IntlDateFormat constructor failure +--INI-- +date.timezone=Mars/Utopia_Planitia +--SKIPIF-- +getMessage(); +} +--EXPECT-- +IntlDateFormatter::__construct(): Invalid date.timezone value 'Mars/Utopia_Planitia', we selected the timezone 'UTC' for now.