Hello Antony,

  in general modifying exception data is vey dangerous because first it
leads to confusion on the usage part and second it might lead to sever
problems in the engine facilities that deal with them. That this in a
few cases worked does not mean it works in all cases it mybe be used.

On another reason we should have a look why Java comes with such a thing.
In Java you don't have automatic stack frame cleaning as you have in c++
for example. Thus when a function might throw an exception which is the
usual case in Java you must catch the exception locally cleanup you local
data manually and rethrow the exception. Now you must understand that Java
took a very differetn design approach than either C++ but even also very
different from PHP. Since C++ is out of interest besides above mentioned
fact we just need to look at Java and PHP. Java has no builtin error
notification facilities like PHP has. Also they don't have pass by
reference. Therefore the only ways to notify of function failures are
returning a functionality info (boolean or error code or even objects),
using exceptions, modifying the objects state. Of these the APIs chose
to use exceptions so everyone else followed this scheme. Now in PHP we
chose to use exceptions only where no other solution is possible (ctor
failure) and have exceptions else for user scenarios where it can be very
helpfull. While in Java exceptions have become normalities and a lot of
stuff has been established to make them even more normal the infrastucture
has always been designed to treat exceptions as a very native, common and
deeply integrated thing. This is pretty different in PHP where exceptions
are a tiny addon.

To prevent us from adding all the stuff Java invented to deal more
gracefull with exceptions starting with the ability to handle more than
one exception at a time i would like to stay with the KISS approach and
have them as easy as possible.

best regards
marcus


Tuesday, January 10, 2006, 2:42:56 PM, you wrote:

> Index: Zend/zend_exceptions.c
> ===================================================================
> RCS file: /repository/ZendEngine2/zend_exceptions.c,v
> retrieving revision 1.94
> diff -u -p -d -r1.94 zend_exceptions.c
> --- Zend/zend_exceptions.c      4 Jan 2006 23:52:06 -0000       1.94
> +++ Zend/zend_exceptions.c      10 Jan 2006 13:24:57 -0000
> @@ -294,6 +294,37 @@ ZEND_METHOD(error_exception, getSeverity
>  }
>  /* }}} */
>  
> +/* {{{ proto int ErrorException::fillException()
> +   Fill in exception properties */
> +ZEND_METHOD(exception, fillException)
> +{
> +       zval *exception = getThis();
> +       zval *trace, tmp;
> +       zend_object *object;
> +       
> +       DEFAULT_0_PARAMS;
> +    
> +       INIT_PZVAL(return_value);
> +       Z_TYPE_P(return_value) = IS_OBJECT;
> +       Z_OBJVAL_P(return_value) = zend_objects_new(&object, 
> Z_OBJCE_P(exception) TSRMLS_CC);
> +       Z_OBJ_HT_P(return_value) = Z_OBJ_HT_P(exception);
> +
> +       ALLOC_HASHTABLE(object->properties);
> +       zend_u_hash_init(object->properties, 0, NULL, ZVAL_PTR_DTOR, 0, 
> UG(unicode));
> +       zend_hash_copy(object->properties, Z_OBJPROP_P(exception),
> (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
> +       
> +       ALLOC_ZVAL(trace);
> +       trace->is_ref = 0;
> +       trace->refcount = 0;
> +
> +       zend_fetch_debug_backtrace(trace, 0, 0 TSRMLS_CC);
> +       
> +       zend_update_property(Z_OBJCE_P(exception), return_value, "trace", 
> sizeof("trace")-1, trace TSRMLS_CC);
> +       zend_update_property_rt_string(Z_OBJCE_P(exception),
> return_value, "file", sizeof("file")-1,
> zend_get_executed_filename(TSRMLS_C) TSRMLS_CC);
> +       zend_update_property_long(Z_OBJCE_P(exception), return_value,
> "line", sizeof("line")-1, zend_get_executed_lineno(TSRMLS_C) TSRMLS_CC);
> +}
> +/* }}} */
> +
>  /* {{{ ZEND_METHOD(exception, gettraceasstring) */
>  #define TRACE_APPEND_CHR(chr)                                            \
>         *str = (char*)erealloc(*str, *len + 1 + 1);                      
> @@ -604,6 +635,7 @@ static zend_function_entry default_excep
>         ZEND_ME(exception, getTrace, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
>         ZEND_ME(exception, getTraceAsString, NULL, 
> ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
>         ZEND_ME(exception, __toString, NULL, 0)
> +       ZEND_ME(exception, fillException, NULL, 
> ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
>         {NULL, NULL, NULL}
>  };
>  




Best regards,
 Marcus

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to