Lines Matching defs:exception

73 void zend_exception_set_previous(zend_object *exception, zend_object *add_previous) /* {{{ */
79 if (!exception || !add_previous) {
83 if (exception == add_previous) {
90 zend_error_noreturn(E_CORE_ERROR, "Previous exception must implement Throwable");
93 ZVAL_OBJ(&zv, exception);
119 zend_exception_set_previous(EG(exception), EG(prev_exception));
121 if (EG(exception)) {
122 EG(prev_exception) = EG(exception);
124 EG(exception) = NULL;
131 if (EG(exception)) {
132 zend_exception_set_previous(EG(exception), EG(prev_exception));
134 EG(exception) = EG(prev_exception);
141 ZEND_API ZEND_COLD void zend_throw_exception_internal(zval *exception) /* {{{ */
145 if (exception != NULL) {
146 DTRACE_EXCEPTION_THROWN(ZSTR_VAL(Z_OBJ_P(exception)->ce->name));
153 if (exception != NULL) {
154 zend_object *previous = EG(exception);
155 zend_exception_set_previous(Z_OBJ_P(exception), EG(exception));
156 EG(exception) = Z_OBJ_P(exception);
162 if (exception && (Z_OBJCE_P(exception) == zend_ce_parse_error || Z_OBJCE_P(exception) == zend_ce_compile_error)) {
165 if(EG(exception)) {
166 zend_exception_error(EG(exception), E_ERROR);
172 zend_throw_exception_hook(exception);
178 /* no need to rethrow the exception */
188 zend_object *exception;
193 if (!EG(exception)) {
196 /* exception may have destructor */
197 exception = EG(exception);
198 EG(exception) = NULL;
199 OBJ_RELEASE(exception);
265 Clone the exception object */
266 ZEND_COLD ZEND_METHOD(exception, __clone)
275 ZEND_METHOD(exception, __construct)
324 ZEND_METHOD(exception, __wakeup)
410 Get the file in which the exception occurred */
411 ZEND_METHOD(exception, getFile)
424 Get the line in which the exception occurred */
425 ZEND_METHOD(exception, getLine)
438 Get the exception message */
439 ZEND_METHOD(exception, getMessage)
452 Get the exception code */
453 ZEND_METHOD(exception, getCode)
466 Get the stack trace for the location in which the exception occurred */
467 ZEND_METHOD(exception, getTrace)
480 Get the exception severity */
623 Obtain the backtrace for the exception as a string (instead of an array) */
624 ZEND_METHOD(exception, getTraceAsString)
662 ZEND_METHOD(exception, getPrevious)
673 ZEND_METHOD(exception, __toString)
675 zval trace, *exception;
686 exception = ZEND_THIS;
689 while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), zend_ce_throwable)) {
691 zend_string *message = zval_get_string(GET_PROPERTY(exception, ZEND_STR_MESSAGE));
692 zend_string *file = zval_get_string(GET_PROPERTY(exception, ZEND_STR_FILE));
693 zend_long line = zval_get_long(GET_PROPERTY(exception, ZEND_STR_LINE));
697 fci.object = Z_OBJ_P(exception);
710 if ((Z_OBJCE_P(exception) == zend_ce_type_error || Z_OBJCE_P(exception) == zend_ce_argument_count_error) && strstr(ZSTR_VAL(message), ", called in ")) {
719 ZSTR_VAL(Z_OBJCE_P(exception)->name), ZSTR_VAL(message), ZSTR_VAL(file), line,
725 ZSTR_VAL(Z_OBJCE_P(exception)->name), ZSTR_VAL(file), line,
735 Z_PROTECT_RECURSION_P(exception);
736 exception = GET_PROPERTY(exception, ZEND_STR_PREVIOUS);
737 if (exception && Z_TYPE_P(exception) == IS_OBJECT && Z_IS_RECURSIVE_P(exception)) {
743 exception = ZEND_THIS;
745 while (exception && Z_TYPE_P(exception) == IS_OBJECT && (base_ce = i_get_exception_base(exception)) && instanceof_function(Z_OBJCE_P(exception), base_ce)) {
746 if (Z_IS_RECURSIVE_P(exception)) {
747 Z_UNPROTECT_RECURSION_P(exception);
751 exception = GET_PROPERTY(exception, ZEND_STR_PREVIOUS);
754 exception = ZEND_THIS;
755 base_ce = i_get_exception_base(exception);
758 * the result in uncaught exception handlers without memleaks. */
760 zend_update_property_ex(base_ce, exception, ZSTR_KNOWN(ZEND_STR_STRING), &tmp);
781 /* All functions that may be used in uncaught exception handlers must be final
797 ZEND_ME(exception, __clone, NULL, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
798 ZEND_ME(exception, __construct, arginfo_exception___construct, ZEND_ACC_PUBLIC)
799 ZEND_ME(exception, __wakeup, NULL, ZEND_ACC_PUBLIC)
800 ZEND_ME(exception, getMessage, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
801 ZEND_ME(exception, getCode, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
802 ZEND_ME(exception, getFile, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
803 ZEND_ME(exception, getLine, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
804 ZEND_ME(exception, getTrace, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
805 ZEND_ME(exception, getPrevious, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
806 ZEND_ME(exception, getTraceAsString, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
807 ZEND_ME(exception, __toString, NULL, 0)
986 zval exception, rv;
989 ZVAL_OBJ(&exception, ex);
991 EG(exception) = NULL;
993 zend_string *message = zval_get_string(GET_PROPERTY(&exception, ZEND_STR_MESSAGE));
994 zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE));
995 zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE));
1007 zend_call_method_with_0_params(&exception, ce_exception, &ex->ce->__tostring, "__tostring", &tmp);
1008 if (!EG(exception)) {
1012 zend_update_property_ex(i_get_exception_base(&exception), &exception, ZSTR_KNOWN(ZEND_STR_STRING), &tmp);
1017 if (EG(exception)) {
1020 ZVAL_OBJ(&zv, EG(exception));
1021 /* do the best we can to inform about the inner exception */
1028 "Uncaught %s in exception handling during call to %s::__tostring()",
1036 str = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_STRING));
1037 file = zval_get_string(GET_PROPERTY_SILENT(&exception, ZEND_STR_FILE));
1038 line = zval_get_long(GET_PROPERTY_SILENT(&exception, ZEND_STR_LINE));
1046 zend_error(severity, "Uncaught exception '%s'", ZSTR_VAL(ce_exception->name));
1053 ZEND_API ZEND_COLD void zend_throw_exception_object(zval *exception) /* {{{ */
1057 if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
1058 zend_error_noreturn(E_CORE_ERROR, "Need to supply an object when throwing an exception");
1061 exception_ce = Z_OBJCE_P(exception);
1065 zval_ptr_dtor(exception);
1068 zend_throw_exception_internal(exception);