summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2004-01-02 19:27:02 +0000
committerAndrei Zmievski <andrei@php.net>2004-01-02 19:27:02 +0000
commit85f62caad270ad7ec2afd826d83d1684e5a41985 (patch)
treefbf438e072796a978cb4e470df26c7a669eeee6e /Zend/zend_exceptions.c
parent0eead3672c4978a88ea845497682eaff9babb401 (diff)
downloadphp-git-85f62caad270ad7ec2afd826d83d1684e5a41985.tar.gz
Do not show exception message if it's empty.
# Is there a way to preserve the case of the exception class here?
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r--Zend/zend_exceptions.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 0e0fa003b2..95d9e7be8a 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -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);