]> granicus.if.org Git - php/commitdiff
- MFH Catch exceptions in cli -a
authorMarcus Boerger <helly@php.net>
Fri, 2 Jan 2009 13:14:49 +0000 (13:14 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 2 Jan 2009 13:14:49 +0000 (13:14 +0000)
Zend/zend.c
Zend/zend_exceptions.c
Zend/zend_exceptions.h
Zend/zend_execute_API.c
sapi/cli/php_cli.c

index f3b702c86713abf4da568b08acbb2f4e73ce0aef..683dd298c9220fcd9dd7047ff890aa36dfe52d0f 100644 (file)
@@ -1199,10 +1199,10 @@ ZEND_API int zend_execute_scripts(int type TSRMLS_DC, zval **retval, int file_co
                                                }
                                        } else {
                                                zend_exception_restore(TSRMLS_C);
-                                               zend_exception_error(EG(exception) TSRMLS_CC);
+                                               zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
                                        }
                                } else {
-                                       zend_exception_error(EG(exception) TSRMLS_CC);
+                                       zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
                                }
                        }
                        destroy_op_array(EG(active_op_array) TSRMLS_CC);
index 55377bfe1176e0f86c525bf0d94c13e6c952b378..369cf9c05c590564e475eb81382d50417fb9aea3 100644 (file)
@@ -739,8 +739,8 @@ static void zend_error_va(int type, const char *file, uint lineno, const char *f
 }
 /* }}} */
 
-/* This function doesn't return as it calls E_ERROR */
-ZEND_API void zend_exception_error(zval *exception TSRMLS_DC) /* {{{ */
+/* This function doesn't return if it uses E_ERROR */
+ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC) /* {{{ */
 {
        zend_class_entry *ce_exception = Z_OBJCE_P(exception);
        if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
@@ -774,9 +774,9 @@ ZEND_API void zend_exception_error(zval *exception TSRMLS_DC) /* {{{ */
                file = zend_read_property(default_exception_ce, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
                line = zend_read_property(default_exception_ce, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
 
-               zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n  thrown", Z_STRVAL_P(str));
+               zend_error_va(severity, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n  thrown", Z_STRVAL_P(str));
        } else {
-               zend_error(E_ERROR, "Uncaught exception '%s'", ce_exception->name);
+               zend_error(severity, "Uncaught exception '%s'", ce_exception->name);
        }
 }
 /* }}} */
index 5a8885f5d04b5db131ede86336ba824af33ba128..3c826e5510d2b7bb1a7961050b5581382cd4b2b9 100644 (file)
@@ -49,8 +49,8 @@ ZEND_API zval * zend_throw_error_exception(zend_class_entry *exception_ce, char
 
 extern ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);
 
-/* show an exception using zend_error(E_ERROR,...) */
-ZEND_API void zend_exception_error(zval *exception TSRMLS_DC);
+/* show an exception using zend_error(severity,...), severity should be E_ERROR */
+ZEND_API void zend_exception_error(zval *exception, int severity TSRMLS_DC);
 
 /* do not export, in php it's available thru spprintf directly */
 int zend_spprintf(char **message, int max_len, char *format, ...);
index 46e8ef73eeaf1abe4b6a491562ece16b7f771935..3bdfc5b6e0a8e75dc91ee12d4b94fbc8abc787b6 100644 (file)
@@ -1184,7 +1184,7 @@ ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name,
 
        result = zend_eval_string(str, retval_ptr, string_name TSRMLS_CC);
        if (handle_exceptions && EG(exception)) {
-               zend_exception_error(EG(exception) TSRMLS_CC);
+               zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
                result = FAILURE;
        }
        return result;
@@ -1253,7 +1253,7 @@ void execute_new_code(TSRMLS_D) /* {{{ */
        zend_execute(CG(active_op_array) TSRMLS_CC);
 
        if (EG(exception)) {
-               zend_exception_error(EG(exception) TSRMLS_CC);
+               zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
        }
 
        CG(active_op_array)->last -= 1; /* get rid of that ZEND_RETURN */
index 519217fa24d8e3b78bb8fd562fc45451aeb6012e..3b72f9469f8dc1f1b3f21057420740d8a3f5deba 100644 (file)
@@ -1123,7 +1123,7 @@ int main(int argc, char *argv[])
                                        }
 
                                        if (EG(exception)) {
-                                               zend_exception_error(EG(exception) TSRMLS_CC);
+                                               zend_exception_error(EG(exception), E_WARNING TSRMLS_CC);
                                        }
 
                                        php_last_char = '\0';