Back to index

php5  5.3.10
Functions | Variables
zend_exceptions.h File Reference

Go to the source code of this file.

Functions

ZEND_API void zend_exception_set_previous (zval *exception, zval *add_previous TSRMLS_DC)
ZEND_API void zend_exception_save (TSRMLS_D)
ZEND_API void zend_exception_restore (TSRMLS_D)
void zend_throw_exception_internal (zval *exception TSRMLS_DC)
void zend_register_default_exception (TSRMLS_D)
ZEND_API zend_class_entry * zend_exception_get_default (TSRMLS_D)
ZEND_API zend_class_entry * zend_get_error_exception (TSRMLS_D)
ZEND_API void zend_register_default_classes (TSRMLS_D)
ZEND_API zval * zend_throw_exception (zend_class_entry *exception_ce, char *message, long code TSRMLS_DC)
ZEND_API zval * zend_throw_exception_ex (zend_class_entry *exception_ce, long code TSRMLS_DC, char *format,...)
ZEND_API void zend_throw_exception_object (zval *exception TSRMLS_DC)
ZEND_API void zend_clear_exception (TSRMLS_D)
ZEND_API zval * zend_throw_error_exception (zend_class_entry *exception_ce, char *message, long code, int severity TSRMLS_DC)
ZEND_API void zend_exception_error (zval *exception, int severity TSRMLS_DC)
int zend_spprintf (char **message, int max_len, char *format,...)

Variables

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

Function Documentation

Definition at line 114 of file zend_exceptions.c.

{
       if (EG(prev_exception)) {
              zval_ptr_dtor(&EG(prev_exception));
              EG(prev_exception) = NULL;
       }
       if (!EG(exception)) {
              return;
       }
       zval_ptr_dtor(&EG(exception));
       EG(exception) = NULL;
       EG(current_execute_data)->opline = EG(opline_before_exception);
#if ZEND_DEBUG
       EG(opline_before_exception) = NULL;
#endif
}

Here is the caller graph for this function:

ZEND_API void zend_exception_error ( zval *  exception,
int severity  TSRMLS_DC 
)

Definition at line 759 of file zend_exceptions.c.

{
       zend_class_entry *ce_exception = Z_OBJCE_P(exception);
       if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
              zval *str, *file, *line;

              EG(exception) = NULL;

              zend_call_method_with_0_params(&exception, ce_exception, NULL, "__tostring", &str);
              if (!EG(exception)) {
                     if (Z_TYPE_P(str) != IS_STRING) {
                            zend_error(E_WARNING, "%s::__toString() must return a string", ce_exception->name);
                     } else {
                            zend_update_property_string(default_exception_ce, exception, "string", sizeof("string")-1, EG(exception) ? ce_exception->name : Z_STRVAL_P(str) TSRMLS_CC);
                     }
              }
              zval_ptr_dtor(&str);

              if (EG(exception)) {
                     /* do the best we can to inform about the inner exception */
                     if (instanceof_function(ce_exception, default_exception_ce TSRMLS_CC)) {
                            file = zend_read_property(default_exception_ce, EG(exception), "file", sizeof("file")-1, 1 TSRMLS_CC);
                            line = zend_read_property(default_exception_ce, EG(exception), "line", sizeof("line")-1, 1 TSRMLS_CC);
                     } else {
                            file = NULL;
                            line = NULL;
                     }
                     zend_error_va(E_WARNING, file ? Z_STRVAL_P(file) : NULL, line ? Z_LVAL_P(line) : 0, "Uncaught %s in exception handling during call to %s::__tostring()", Z_OBJCE_P(EG(exception))->name, ce_exception->name);
              }

              str = zend_read_property(default_exception_ce, exception, "string", sizeof("string")-1, 1 TSRMLS_CC);
              file = zend_read_property(default_exception_ce, exception, "file", sizeof("file")-1, 1 TSRMLS_CC);
              line = zend_read_property(default_exception_ce, exception, "line", sizeof("line")-1, 1 TSRMLS_CC);

              zend_error_va(severity, Z_STRVAL_P(file), Z_LVAL_P(line), "Uncaught %s\n  thrown", Z_STRVAL_P(str));
       } else {
              zend_error(severity, "Uncaught exception '%s'", ce_exception->name);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zend_class_entry* zend_exception_get_default ( TSRMLS_D  )

Definition at line 685 of file zend_exceptions.c.

Here is the caller graph for this function:

Definition at line 70 of file zend_exceptions.c.

{
       if (EG(prev_exception)) {
              if (EG(exception)) {
                     zend_exception_set_previous(EG(exception), EG(prev_exception) TSRMLS_CC);
              } else {
                     EG(exception) = EG(prev_exception);
              }
              EG(prev_exception) = NULL;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 58 of file zend_exceptions.c.

{
       if (EG(prev_exception)) {
              zend_exception_set_previous(EG(exception), EG(prev_exception) TSRMLS_CC);
       }
       if (EG(exception)) {
              EG(prev_exception) = EG(exception);
       }
       EG(exception) = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_exception_set_previous ( zval *  exception,
zval *add_previous  TSRMLS_DC 
)

Definition at line 36 of file zend_exceptions.c.

{
       zval *previous;

       if (exception == add_previous || !add_previous || !exception) {
              return;
       }
       if (Z_TYPE_P(add_previous) != IS_OBJECT && !instanceof_function(Z_OBJCE_P(add_previous), default_exception_ce TSRMLS_CC)) {
              zend_error(E_ERROR, "Cannot set non exception as previous exception");
              return;
       }
       while (exception && exception != add_previous && Z_OBJ_HANDLE_P(exception) != Z_OBJ_HANDLE_P(add_previous)) {
              previous = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
              if (Z_TYPE_P(previous) == IS_NULL) {
                     zend_update_property(default_exception_ce, exception, "previous", sizeof("previous")-1, add_previous TSRMLS_CC);
                     Z_DELREF_P(add_previous);
                     return;
              }
              exception = previous;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zend_class_entry* zend_get_error_exception ( TSRMLS_D  )

Definition at line 691 of file zend_exceptions.c.

{
       return error_exception_ce;
}

Definition at line 30 of file zend_default_classes.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 660 of file zend_exceptions.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int zend_spprintf ( char **  message,
int  max_len,
char *  format,
  ... 
)

Definition at line 526 of file zend_exceptions.c.

{
       va_list arg;
       int len;

       va_start(arg, format);
       len = zend_vspprintf(message, max_len, format, arg);
       va_end(arg);
       return len;
}

Here is the caller graph for this function:

ZEND_API zval* zend_throw_error_exception ( zend_class_entry *  exception_ce,
char *  message,
long  code,
int severity  TSRMLS_DC 
)

Definition at line 740 of file zend_exceptions.c.

{
       zval *ex = zend_throw_exception(exception_ce, message, code TSRMLS_CC);
       zend_update_property_long(default_exception_ce, ex, "severity", sizeof("severity")-1, severity TSRMLS_CC);
       return ex;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zval* zend_throw_exception ( zend_class_entry *  exception_ce,
char *  message,
long code  TSRMLS_DC 
)

Definition at line 697 of file zend_exceptions.c.

{
       zval *ex;

       MAKE_STD_ZVAL(ex);
       if (exception_ce) {
              if (!instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) {
                     zend_error(E_NOTICE, "Exceptions must be derived from the Exception base class");
                     exception_ce = default_exception_ce;
              }
       } else {
              exception_ce = default_exception_ce;
       }
       object_init_ex(ex, exception_ce);


       if (message) {
              zend_update_property_string(default_exception_ce, ex, "message", sizeof("message")-1, message TSRMLS_CC);
       }
       if (code) {
              zend_update_property_long(default_exception_ce, ex, "code", sizeof("code")-1, code TSRMLS_CC);
       }

       zend_throw_exception_internal(ex TSRMLS_CC);
       return ex;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API zval* zend_throw_exception_ex ( zend_class_entry *  exception_ce,
long code  TSRMLS_DC,
char *  format,
  ... 
)

Definition at line 725 of file zend_exceptions.c.

{
       va_list arg;
       char *message;
       zval *zexception;

       va_start(arg, format);
       zend_vspprintf(&message, 0, format, arg);
       va_end(arg);
       zexception = zend_throw_exception(exception_ce, message, code TSRMLS_CC);
       efree(message);
       return zexception;
}

Here is the call graph for this function:

void zend_throw_exception_internal ( zval *exception  TSRMLS_DC)

Definition at line 83 of file zend_exceptions.c.

{
       if (exception != NULL) {
              zval *previous = EG(exception);
              zend_exception_set_previous(exception, EG(exception) TSRMLS_CC);
              EG(exception) = exception;
              if (previous) {
                     return;
              }
       }
       if (!EG(current_execute_data)) {
              if(EG(exception)) {
                     zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
              }
              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 == NULL ||
           (EG(current_execute_data)->opline+1)->opcode == ZEND_HANDLE_EXCEPTION) {
              /* no need to rethrow the exception */
              return;
       }
       EG(opline_before_exception) = EG(current_execute_data)->opline;
       EG(current_execute_data)->opline = EG(exception_op);
}

Here is the call graph for this function:

Here is the caller graph for this function:

ZEND_API void zend_throw_exception_object ( zval *exception  TSRMLS_DC)

Definition at line 800 of file zend_exceptions.c.

{
       zend_class_entry *exception_ce;

       if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
              zend_error(E_ERROR, "Need to supply an object when throwing an exception");
       }

       exception_ce = Z_OBJCE_P(exception);

       if (!exception_ce || !instanceof_function(exception_ce, default_exception_ce TSRMLS_CC)) {
              zend_error(E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
       }
       zend_throw_exception_internal(exception TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 34 of file zend_exceptions.c.