Skip to content

Commit dace607

Browse files
committed
Fix exception types
1 parent 0cbe010 commit dace607

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ext/date/php_date.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,7 +4131,7 @@ PHP_METHOD(DatePeriod, __construct)
41314131
dpobj->current = NULL;
41324132

41334133
if (isostr) {
4134-
zend_replace_error_handling(EH_THROW, NULL, &error_handling);
4134+
zend_replace_error_handling(EH_THROW, zend_ce_value_error, &error_handling);
41354135
date_period_initialize(&(dpobj->start), &(dpobj->end), &(dpobj->interval), &recurrences, isostr, isostr_len);
41364136
zend_restore_error_handling(&error_handling);
41374137
if (EG(exception)) {
@@ -4140,19 +4140,19 @@ PHP_METHOD(DatePeriod, __construct)
41404140

41414141
if (dpobj->start == NULL) {
41424142
zend_string *func = get_active_function_or_method_name();
4143-
zend_throw_error(NULL, "%s(): Argument #1 must contain a start date, \"%s\" given", ZSTR_VAL(func), isostr);
4143+
zend_value_error("%s(): Argument #1 must contain a start date, \"%s\" given", ZSTR_VAL(func), isostr);
41444144
zend_string_release(func);
41454145
RETURN_THROWS();
41464146
}
41474147
if (dpobj->interval == NULL) {
41484148
zend_string *func = get_active_function_or_method_name();
4149-
zend_throw_error(NULL, "%s(): Argument #1 must contain an interval, \"%s\" given", ZSTR_VAL(func), isostr);
4149+
zend_value_error("%s(): Argument #1 must contain an interval, \"%s\" given", ZSTR_VAL(func), isostr);
41504150
zend_string_release(func);
41514151
RETURN_THROWS();
41524152
}
41534153
if (dpobj->end == NULL && recurrences == 0) {
41544154
zend_string *func = get_active_function_or_method_name();
4155-
zend_throw_error(NULL, "%s(): Argument #1 must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr);
4155+
zend_value_error("%s(): Argument #1 must contain an end date or a recurrence count, \"%s\" given", ZSTR_VAL(func), isostr);
41564156
zend_string_release(func);
41574157
RETURN_THROWS();
41584158
}
@@ -4194,7 +4194,7 @@ PHP_METHOD(DatePeriod, __construct)
41944194

41954195
if (dpobj->end == NULL && recurrences < 1) {
41964196
zend_string *func = get_active_function_or_method_name();
4197-
zend_throw_error(NULL, "%s(): Recurrence count must be greater than 0", ZSTR_VAL(func));
4197+
zend_value_error("%s(): Recurrence count must be greater than 0", ZSTR_VAL(func));
41984198
zend_string_release(func);
41994199
RETURN_THROWS();
42004200
}

ext/date/tests/DatePeriod_wrong_recurrence_on_constructor.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ DatePeriod: Test wrong recurrence parameter on __construct
44
<?php
55
try {
66
new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), 0);
7-
} catch (Exception $exception) {
7+
} catch (ValueError $exception) {
88
echo $exception->getMessage(), "\n";
99
}
1010

1111
try {
1212
new DatePeriod(new DateTime('yesterday'), new DateInterval('P1D'), -1);
13-
} catch (Exception $exception) {
13+
} catch (ValueError $exception) {
1414
echo $exception->getMessage(), "\n";
1515
}
1616

0 commit comments

Comments
 (0)