Skip to content

Commit 1001fb9

Browse files
committed
Use Exception instead of Error for some conditions
1 parent 7d53864 commit 1001fb9

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

ext/session/session.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static void php_session_initialize(void) /* {{{ */
529529
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
530530
if (!PS(id)) {
531531
php_session_abort();
532-
zend_throw_error(NULL, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
532+
zend_throw_exception_ex(NULL, 0, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
533533
return;
534534
}
535535
if (PS(use_cookies)) {
@@ -2130,14 +2130,14 @@ static PHP_FUNCTION(session_regenerate_id)
21302130

21312131
if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE) {
21322132
PS(session_status) = php_session_none;
2133-
zend_throw_error(NULL, "Failed to open session: %s (path: %s)", PS(mod)->s_name, PS(save_path));
2133+
zend_throw_exception_ex(NULL, 0, "Failed to open session: %s (path: %s)", PS(mod)->s_name, PS(save_path));
21342134
RETURN_FALSE;
21352135
}
21362136

21372137
PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
21382138
if (!PS(id)) {
21392139
PS(session_status) = php_session_none;
2140-
zend_throw_error(NULL, "Failed to create new session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
2140+
zend_throw_exception_ex(NULL, 0, "Failed to create new session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
21412141
RETURN_FALSE;
21422142
}
21432143
if (PS(use_strict_mode) && PS(mod)->s_validate_sid &&
@@ -2147,15 +2147,15 @@ static PHP_FUNCTION(session_regenerate_id)
21472147
if (!PS(id)) {
21482148
PS(mod)->s_close(&PS(mod_data));
21492149
PS(session_status) = php_session_none;
2150-
zend_throw_error(NULL, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path));
2150+
zend_throw_exception_ex(NULL, 0, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path));
21512151
RETURN_FALSE;
21522152
}
21532153
}
21542154
/* Read is required to make new session data at this point. */
21552155
if (PS(mod)->s_read(&PS(mod_data), PS(id), &data, PS(gc_maxlifetime)) == FAILURE) {
21562156
PS(mod)->s_close(&PS(mod_data));
21572157
PS(session_status) = php_session_none;
2158-
zend_throw_error(NULL, "Failed to create(read) session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
2158+
zend_throw_exception_ex(NULL, 0, "Failed to create(read) session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
21592159
RETURN_FALSE;
21602160
}
21612161
if (data) {

ext/session/tests/session_set_save_handler_sid_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Stack trace:
7979
#0 %s(%d): session_start()
8080
#1 {main}
8181

82-
Next Error: Failed to create session ID: user (path: ) in %s:%d
82+
Next Exception: Failed to create session ID: user (path: ) in %s:%d
8383
Stack trace:
8484
#0 %s(%d): session_start()
8585
#1 {main}

ext/standard/php_fopen_wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
195195
path += 11;
196196
max_memory = ZEND_STRTOL(path, NULL, 10);
197197
if (max_memory < 0) {
198-
zend_throw_error(NULL, "Max memory must be >= 0");
198+
zend_throw_exception(NULL, "Max memory must be >= 0");
199199
return NULL;
200200
}
201201
}
@@ -353,7 +353,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
353353
pathdup = estrndup(path + 6, strlen(path + 6));
354354
p = strstr(pathdup, "/resource=");
355355
if (!p) {
356-
zend_throw_error(NULL, "No URL resource specified");
356+
zend_throw_exception(NULL, "No URL resource specified");
357357
efree(pathdup);
358358
return NULL;
359359
}

0 commit comments

Comments
 (0)