]> granicus.if.org Git - php/commitdiff
Do not show exception message if it's empty.
authorAndrei Zmievski <andrei@php.net>
Fri, 2 Jan 2004 19:27:02 +0000 (19:27 +0000)
committerAndrei Zmievski <andrei@php.net>
Fri, 2 Jan 2004 19:27:02 +0000 (19:27 +0000)
# Is there a way to preserve the case of the exception class here?

Zend/zend_default_classes.c
Zend/zend_exceptions.c

index 0e0fa003b270e2912f2fd8dbd3cf39843b29f342..95d9e7be8abfc7bfbfac11c387e8ce556d211248 100644 (file)
@@ -340,9 +340,15 @@ ZEND_METHOD(exception, __toString)
 
        zend_call_function(&fci, NULL TSRMLS_CC);
 
-       len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", 
-               Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), 
-               Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       if (Z_STRLEN_P(message) > 0) {
+               len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", 
+                                                       Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), 
+                                                       Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       } else {
+               len = zend_spprintf(&str, 0, "exception '%s' in %s:%ld\nStack trace:\n%s", 
+                                                       Z_OBJCE_P(getThis())->name, Z_STRVAL_P(file), Z_LVAL_P(line), 
+                                                       Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       }
 
        /* We store the result in the private property string so we can access
         * the result in uncaught exception handlers without memleaks. */
@@ -385,7 +391,7 @@ static void zend_register_default_exception(TSRMLS_D)
        memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
        default_exception_handlers.clone_obj = NULL;
 
-       zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "none", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
        zend_declare_property_string(default_exception_ptr, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
        zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
        zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC);
index 0e0fa003b270e2912f2fd8dbd3cf39843b29f342..95d9e7be8abfc7bfbfac11c387e8ce556d211248 100644 (file)
@@ -340,9 +340,15 @@ ZEND_METHOD(exception, __toString)
 
        zend_call_function(&fci, NULL TSRMLS_CC);
 
-       len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", 
-               Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), 
-               Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       if (Z_STRLEN_P(message) > 0) {
+               len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s", 
+                                                       Z_OBJCE_P(getThis())->name, Z_STRVAL_P(message), Z_STRVAL_P(file), Z_LVAL_P(line), 
+                                                       Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       } else {
+               len = zend_spprintf(&str, 0, "exception '%s' in %s:%ld\nStack trace:\n%s", 
+                                                       Z_OBJCE_P(getThis())->name, Z_STRVAL_P(file), Z_LVAL_P(line), 
+                                                       Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
+       }
 
        /* We store the result in the private property string so we can access
         * the result in uncaught exception handlers without memleaks. */
@@ -385,7 +391,7 @@ static void zend_register_default_exception(TSRMLS_D)
        memcpy(&default_exception_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
        default_exception_handlers.clone_obj = NULL;
 
-       zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "none", ZEND_ACC_PROTECTED TSRMLS_CC);
+       zend_declare_property_string(default_exception_ptr, "message", sizeof("message")-1, "", ZEND_ACC_PROTECTED TSRMLS_CC);
        zend_declare_property_string(default_exception_ptr, "string", sizeof("string")-1, "", ZEND_ACC_PRIVATE TSRMLS_CC);
        zend_declare_property_long(default_exception_ptr, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED TSRMLS_CC);
        zend_declare_property_null(default_exception_ptr, "file", sizeof("file")-1, ZEND_ACC_PROTECTED TSRMLS_CC);