internal bool RecordFailure(Exception e, InternalCommand command) { bool stopping = false; lock (this.StopReasonLock) { if (this.firstTerminatingError == null) { RuntimeException.LockStackTrace(e); this.firstTerminatingError = e; } else if ((!(this.firstTerminatingError is PipelineStoppedException) && (command != null)) && (command.Context != null)) { Exception innerException = e; while (((innerException is TargetInvocationException) || (innerException is CmdletInvocationException)) && (innerException.InnerException != null)) { innerException = innerException.InnerException; } if (!(innerException is PipelineStoppedException)) { InvalidOperationException exception = new InvalidOperationException(StringUtil.Format(PipelineStrings.SecondFailure, new object[] { this.firstTerminatingError.GetType().Name, this.firstTerminatingError.StackTrace, innerException.GetType().Name, innerException.StackTrace }), innerException); MshLog.LogCommandHealthEvent(command.Context, exception, Severity.Warning); } } stopping = this.stopping; this.stopping = true; } return(!stopping); }
public override Collection <PSObject> Invoke(IEnumerable input) { using (PipelineBase._trace.TraceMethod()) { if (this._disposed) { throw PipelineBase._trace.NewObjectDisposedException("pipeline"); } this.CoreInvoke(input, true); this.PipelineFinishedEvent.WaitOne(); if (this.SyncInvokeCall) { this.RaisePipelineStateEvents(); } if (this.PipelineStateInfo.State == PipelineState.Stopped) { return(new Collection <PSObject>()); } if (this.PipelineStateInfo.State == PipelineState.Failed && this.PipelineStateInfo.Reason != null) { PipelineBase._trace.TraceException(this.PipelineStateInfo.Reason); RuntimeException.LockStackTrace(this.PipelineStateInfo.Reason); throw this.PipelineStateInfo.Reason; } return(this.Output.NonBlockingRead(int.MaxValue)); } }
internal Array DoComplete() { if (this.Stopping) { throw new PipelineStoppedException(); } if (!this.executionStarted) { throw PSTraceSource.NewInvalidOperationException("PipelineStrings", "PipelineNotStarted", new object[0]); } Exception firstTerminatingError = null; try { this.DoCompleteCore(null); Hashtable errorResults = new Hashtable(); return(this.RetrieveResults(errorResults)); } catch (RuntimeException exception2) { if (this.firstTerminatingError != null) { firstTerminatingError = this.firstTerminatingError; } else { firstTerminatingError = exception2; } this.LogExecutionException(firstTerminatingError); } catch (InvalidComObjectException exception3) { if (this.firstTerminatingError != null) { firstTerminatingError = this.firstTerminatingError; } else { firstTerminatingError = new RuntimeException(StringUtil.Format(ParserStrings.InvalidComObjectException, exception3.Message), exception3); ((RuntimeException)firstTerminatingError).SetErrorId("InvalidComObjectException"); } this.LogExecutionException(firstTerminatingError); } finally { this.DisposeCommands(); } RuntimeException.LockStackTrace(firstTerminatingError); throw firstTerminatingError; }
public override Collection <PSObject> Invoke(IEnumerable input) { if (this._disposed) { throw PSTraceSource.NewObjectDisposedException("pipeline"); } this.CoreInvoke(input, true); this.PipelineFinishedEvent.WaitOne(); if (this.SyncInvokeCall) { this.RaisePipelineStateEvents(); } if (this.PipelineStateInfo.State == System.Management.Automation.Runspaces.PipelineState.Stopped) { return(new Collection <PSObject>()); } if ((this.PipelineStateInfo.State == System.Management.Automation.Runspaces.PipelineState.Failed) && (this.PipelineStateInfo.Reason != null)) { RuntimeException.LockStackTrace(this.PipelineStateInfo.Reason); throw this.PipelineStateInfo.Reason; } return(this.Output.NonBlockingRead(0x7fffffff)); }
internal Array SynchronousExecuteEnumerate(object input, Hashtable errorResults, bool enumerate) { if (this.Stopping) { throw new PipelineStoppedException(); } Exception exception = null; try { CommandProcessorBase commandRequestingUpstreamCommandsToStop = null; try { this.Start(input != AutomationNull.Value); CommandProcessorBase base3 = this._commands[0]; if (this.ExternalInput != null) { base3.CommandRuntime.InputPipe.ExternalReader = this.ExternalInput; } this.Inject(input, enumerate); } catch (PipelineStoppedException) { StopUpstreamCommandsException firstTerminatingError = this.firstTerminatingError as StopUpstreamCommandsException; if (firstTerminatingError == null) { throw; } this.firstTerminatingError = null; commandRequestingUpstreamCommandsToStop = firstTerminatingError.RequestingCommandProcessor; } this.DoCompleteCore(commandRequestingUpstreamCommandsToStop); if (this._redirectionPipes != null) { foreach (PipelineProcessor processor in this._redirectionPipes) { processor.DoCompleteCore(null); } } return(this.RetrieveResults(errorResults)); } catch (RuntimeException exception3) { if (this.firstTerminatingError != null) { exception = this.firstTerminatingError; } else { exception = exception3; } this.LogExecutionException(exception); } catch (InvalidComObjectException exception4) { if (this.firstTerminatingError != null) { exception = this.firstTerminatingError; } else { exception = new RuntimeException(StringUtil.Format(ParserStrings.InvalidComObjectException, exception4.Message), exception4); ((RuntimeException)exception).SetErrorId("InvalidComObjectException"); } this.LogExecutionException(exception); } finally { this.DisposeCommands(); } RuntimeException.LockStackTrace(exception); throw exception; }