Skip to content

Commit

Permalink
- Add hook for exception handler (Derick)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Gutmans committed Apr 13, 2004
1 parent 254c8d6 commit 979da66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Zend/zend.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions, i
zend_compile_file = compile_file;
zend_execute = execute;
zend_execute_internal = NULL;
zend_throw_exception_hook = NULL;

zend_init_opcodes_handlers();

Expand Down
5 changes: 5 additions & 0 deletions Zend/zend_exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
zend_class_entry *default_exception_ce;
static zend_object_handlers default_exception_handlers;
ZEND_API void zend_throw_exception(zend_class_entry *exception_ce, char *message, long code TSRMLS_DC);
ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);


void zend_throw_exception_internal(zval *exception TSRMLS_DC)
Expand All @@ -45,6 +46,10 @@ void zend_throw_exception_internal(zval *exception TSRMLS_DC)
zend_error(E_ERROR, "Exception thrown without a stack frame");
}

if (zend_throw_exception_hook) {
zend_throw_exception_hook(exception TSRMLS_CC);
}

if ((EG(current_execute_data)->opline+1)->opcode == ZEND_HANDLE_EXCEPTION) {
/* no need to rethrow the exception */
return;
Expand Down
2 changes: 2 additions & 0 deletions Zend/zend_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ ZEND_API void zend_throw_exception_ex(zend_class_entry *exception_ce, long code
ZEND_API void zend_throw_exception_object(zval *exception TSRMLS_DC);
ZEND_API void zend_clear_exception(TSRMLS_D);

ZEND_API void (*zend_throw_exception_hook)(zval *ex TSRMLS_DC);

/* show an exception using zend_error(E_ERROR,...) */
ZEND_API void zend_exception_error(zval *exception TSRMLS_DC);

Expand Down

0 comments on commit 979da66

Please sign in to comment.