]> granicus.if.org Git - php/commitdiff
- Better error message in case of an exception from a dtor while an
authorMarcus Boerger <helly@php.net>
Sat, 20 May 2006 18:32:33 +0000 (18:32 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 20 May 2006 18:32:33 +0000 (18:32 +0000)
  exception is already pending

Zend/zend_objects.c

index d68ae795e2b4168528200032ed81b206586a831e..c2d995517e73db38b109ed268288687024055d14 100644 (file)
@@ -24,6 +24,7 @@
 #include "zend_variables.h"
 #include "zend_API.h"
 #include "zend_interfaces.h"
+#include "zend_exceptions.h"
 
 ZEND_API void zend_object_std_init(zend_object *object, zend_class_entry *ce TSRMLS_DC)
 {
@@ -50,7 +51,6 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
 {
        zend_function *destructor = object->ce->destructor;
 
-
        if (destructor) {
                zval zobj, *obj = &zobj;
                zval *old_exception;
@@ -96,10 +96,15 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
                 */
                old_exception = EG(exception);
                EG(exception) = NULL;
-               zend_call_method_with_0_params(&obj, object->ce, &object->ce->destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL);
+               zend_call_method_with_0_params(&obj, object->ce, &destructor, ZEND_DESTRUCTOR_FUNC_NAME, NULL);
                if (old_exception) {
                        if (EG(exception)) {
-                               zend_error(E_ERROR, "Ignoring exception from %v::__destruct() while an exception is already active", object->ce->name);
+                               zend_class_entry *default_exception_ce = zend_exception_get_default(TSRMLS_C);
+                               zval *file = zend_read_property(default_exception_ce, old_exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
+                               zval *line = zend_read_property(default_exception_ce, old_exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
+
+                               zend_error(E_ERROR, "Ignoring exception from %v::__destruct() while an exception is already active (Uncaught %v in %R on line %d)", 
+                                       object->ce->name, Z_OBJCE_P(old_exception)->name, Z_TYPE_P(file), Z_UNIVAL_P(file), Z_LVAL_P(line));
                                zval_ptr_dtor(&EG(exception));
                        }
                        EG(exception) = old_exception;