示例#1
0
        /// <summary>
        /// block the ps thread until ACK message or Error happened.
        /// </summary>
        private void WaitForAckMessage()
        {
            DebugHelper.WriteLogEx();
            this.ackedEvent.Wait();
            if (this.exception != null)
            {
                DebugHelper.WriteLogEx("error happened", 0);
                if (this.Cmdlet != null)
                {
                    DebugHelper.WriteLogEx("Throw Terminating error", 1);

                    // throw terminating error
                    ErrorRecord errorRecord = ErrorToErrorRecord.ErrorRecordFromAnyException(
                        new InvocationContext(this.TargetComputerName, null), this.exception, null);
                    this.Cmdlet.ThrowTerminatingError(errorRecord);
                }
                else
                {
                    DebugHelper.WriteLogEx("Throw exception", 1);
                    // throw exception out
                    throw this.exception;
                }
            }
            DebugHelper.WriteLogEx("ACK happened", 0);
        }
示例#2
0
        public override void Execute(CmdletOperationBase cmdlet)
        {
            Exception cimException;

            try
            {
                try
                {
                    if (this.error != null)
                    {
                        cimException = new CimException(this.error);
                    }
                    else
                    {
                        cimException = this.Exception;
                    }
                    Exception exception = cimException;
                    cmdlet.WriteError(ErrorToErrorRecord.ErrorRecordFromAnyException(this.invocationContext, exception, this.cimResultContext));
                    this.responseType = CimResponseType.Yes;
                }
                catch
                {
                    this.responseType = CimResponseType.NoToAll;
                    throw;
                }
            }
            finally
            {
                this.OnComplete();
            }
        }
示例#3
0
        /// <summary>
        /// <para>
        /// Write error to pipeline
        /// </para>
        /// </summary>
        /// <param name="cmdlet"></param>
        public override void Execute(CmdletOperationBase cmdlet)
        {
            Debug.Assert(cmdlet != null, "Caller should verify that cmdlet != null");
            try
            {
                Exception errorException = (error != null) ? new CimException(error) : this.Exception;

                // PS engine takes care of handling error action
                cmdlet.WriteError(ErrorToErrorRecord.ErrorRecordFromAnyException(this.invocationContext, errorException, this.cimResultContext));

                // if user wants to continue, we will get here
                this.responseType = CimResponseType.Yes;
            }
            catch
            {
                this.responseType = CimResponseType.NoToAll;
                throw;
            }
            finally
            {
                // unblocking the waiting thread
                this.OnComplete();
            }
        }