/// <summary> /// Invoked by runtime when PHP assertion fails. /// </summary> protected virtual void AssertFailed(PhpValue action = default) { // exception to be thrown var userexception = action.IsSet ? action.AsObject() as Exception : null; var usermessage = action.IsSet ? action.AsString() : null; var exception = userexception ?? PhpException.AssertionErrorException(usermessage ?? string.Empty); throw exception; }
/// <summary> /// Invoked by runtime when PHP assertion fails. /// </summary> protected virtual void AssertFailed(PhpValue action = default(PhpValue)) { const string AssertionErrorName = "AssertionError"; var t_assertex = GetDeclaredType(AssertionErrorName); Debug.Assert(t_assertex != null); Exception exception; // exception to be thrown if (action.IsSet && !action.IsEmpty) { var description = action.AsString(); exception = action.AsObject() as Exception ?? (Exception)t_assertex.Creator(this, (PhpValue)description); } else { exception = (Exception)t_assertex.Creator(this); } // throw exception; }