summaryrefslogtreecommitdiff
path: root/Zend/zend_default_classes.c
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2003-08-24 13:10:03 +0000
committerMarcus Boerger <helly@php.net>2003-08-24 13:10:03 +0000
commitd3473d1f58c3801805ceac5c6c7df839d12c2a04 (patch)
treed6894bbf5392bc02eaca1ecb81a90546bb38d73a /Zend/zend_default_classes.c
parent669603f69d7133053e5c1b888caa229c7e5b276a (diff)
downloadphp-git-d3473d1f58c3801805ceac5c6c7df839d12c2a04.tar.gz
- Provide a unified way to display uncaught exceptions, which shows
file/line/message info if possible. - Add zend_eval_string_ex() to be able to handle exceptions in eval'd code. - Use above function to fix memleaks in CLI.
Diffstat (limited to 'Zend/zend_default_classes.c')
-rw-r--r--Zend/zend_default_classes.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/Zend/zend_default_classes.c b/Zend/zend_default_classes.c
index 73a78d8fd6..a00d261ea7 100644
--- a/Zend/zend_default_classes.c
+++ b/Zend/zend_default_classes.c
@@ -153,6 +153,27 @@ ZEND_API void zend_throw_exception(char *message, long code TSRMLS_DC)
EG(exception) = ex;
}
+static void zend_error_va(int type, const char *file, uint lineno, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ zend_error_cb(E_ERROR, file, lineno, format, args);
+ va_end(args);
+}
+
+ZEND_API void zend_exception_error(zval *exception TSRMLS_DC)
+{
+ if (instanceof_function(Z_OBJCE_P(exception), default_exception_ptr TSRMLS_CC)) {
+ zval *message = zend_read_property(default_exception_ptr, exception, "message", sizeof("message")-1, 1 TSRMLS_CC);
+ zval *file = zend_read_property(default_exception_ptr, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
+ zval *lineno = zend_read_property(default_exception_ptr, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);
+ zend_error_va(E_ERROR, Z_STRVAL_P(file), Z_LVAL_P(lineno), "Uncaught exception '%s' with message '%s'", Z_OBJCE_P(exception)->name, Z_STRVAL_P(message));
+ } else {
+ zend_error(E_ERROR, "Uncaught exception '%s'!", Z_OBJCE_P(exception)->name);
+ }
+}
+
ZEND_API void zend_register_default_classes(TSRMLS_D)
{
zend_register_default_exception(TSRMLS_C);