summaryrefslogtreecommitdiff
path: root/Zend/zend_exceptions.c
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2015-05-17 18:59:34 +0200
committerNikita Popov <nikic@php.net>2015-05-17 19:54:12 +0200
commit440481fb3e15d78d0d92432c3adba9067989f43a (patch)
tree9a083b31d5b1987a09f0f36589099c01181cd7ed /Zend/zend_exceptions.c
parent3ae995f03c8f60c4a4c9718262545cf5a6a08da3 (diff)
downloadphp-git-440481fb3e15d78d0d92432c3adba9067989f43a.tar.gz
Display TypeExceptions like normal exceptions
We currently don't show the argument at which the error actually occured in the trace - should probably either add it or don't display args on incomplete frames altogether, otherwise this'll probably be confusing.
Diffstat (limited to 'Zend/zend_exceptions.c')
-rw-r--r--Zend/zend_exceptions.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 94a51cf1ef..9ad221d695 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -652,6 +652,12 @@ ZEND_METHOD(exception, __toString)
ZVAL_UNDEF(&trace);
}
+ if (Z_OBJCE_P(exception) == type_exception_ce && strstr(message->val, ", called in ")) {
+ zend_string *real_message = zend_strpprintf(0, "%s and defined", message->val);
+ zend_string_release(message);
+ message = real_message;
+ }
+
if (message->len > 0) {
str = zend_strpprintf(0, "%s: %s in %s:" ZEND_LONG_FMT
"\nStack trace:\n%s%s%s",
@@ -908,17 +914,13 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
ZVAL_OBJ(&exception, ex);
ce_exception = Z_OBJCE(exception);
EG(exception) = NULL;
- if (ce_exception == parse_exception_ce || ce_exception == type_exception_ce) {
+ if (ce_exception == parse_exception_ce) {
zend_string *message = zval_get_string(GET_PROPERTY(&exception, "message"));
zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, "file"));
zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, "line"));
zend_long code = zval_get_long(GET_PROPERTY_SILENT(&exception, "code"));
- if (ce_exception == type_exception_ce && strstr(message->val, ", called in ")) {
- zend_error_helper(code, file->val, line, "%s and defined", message->val);
- } else {
- zend_error_helper(code, file->val, line, "%s", message->val);
- }
+ zend_error_helper(code, file->val, line, "%s", message->val);
zend_string_release(file);
zend_string_release(message);