// Token: 0x060010CA RID: 4298 RVA: 0x00033B8C File Offset: 0x00031D8C private ErrorRecord ResolveErrorRecord(ErrorRecord errorRecord) { RemoteException ex = errorRecord.Exception as RemoteException; if (ex != null) { return(new ErrorRecord(MonadCommand.DeserializeException(ex), errorRecord.FullyQualifiedErrorId, errorRecord.CategoryInfo.Category, errorRecord.TargetObject)); } return(errorRecord); }
// Token: 0x060010C7 RID: 4295 RVA: 0x000337D4 File Offset: 0x000319D4 private Collection <PSObject> ClosePipeline(MonadAsyncResult asyncResult) { ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "-->MonadCommand.ClosePipeline()"); if (base.PowerShell == null) { throw new InvalidOperationException("The command is not currently executing."); } Exception ex = null; Collection <PSObject> result = new Collection <PSObject>(); ExTraceGlobals.VerboseTracer.Information((long)this.GetHashCode(), "\tWaiting for the pipeline to finish."); try { base.PowerShell.EndInvoke(asyncResult.PowerShellIAsyncResult); } catch (Exception) { ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "\tPipeline End Invoke Fired an Exception."); if (base.PowerShell.InvocationStateInfo.Reason == null) { throw; } } ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "\tPipeline finished."); if (base.PowerShell.InvocationStateInfo.State == PSInvocationState.Completed && base.PowerShell.Streams.Error.Count == 0) { result = asyncResult.Output.ReadAll(); } else if (base.PowerShell.InvocationStateInfo.State == PSInvocationState.Stopped || base.PowerShell.InvocationStateInfo.State == PSInvocationState.Failed || base.PowerShell.Streams.Error.Count > 0) { ex = MonadCommand.DeserializeException(base.PowerShell.InvocationStateInfo.Reason); if (ex != null && (this.IsHandledException(ex) || base.PowerShell.InvocationStateInfo.State == PSInvocationState.Stopped)) { ThrowTerminatingErrorException ex2 = ex as ThrowTerminatingErrorException; ErrorRecord errorRecord; if (ex2 != null) { errorRecord = ex2.ErrorRecord; } else { errorRecord = new ErrorRecord(ex, LocalizedException.GenerateErrorCode(ex).ToString("X"), ErrorCategory.InvalidOperation, null); } if (base.WorkUnits != null) { for (int i = 0; i < base.WorkUnits.Length; i++) { if (base.WorkUnits[i].CurrentStatus == 2) { if (base.PowerShell.InvocationStateInfo.State != PSInvocationState.Stopped) { this.lastUnhandledError = errorRecord; break; } } else { base.ReportError(errorRecord, i); base.WorkUnits[i].CurrentStatus = 3; } } } else { base.ReportError(errorRecord, -1); } ex = null; } if (ex == null) { result = asyncResult.Output.ReadAll(); base.DrainErrorStream(-1); } asyncResult.Output.Complete(); base.PowerShell.Streams.Error.Complete(); } this.pipelineStateAtClose = base.PowerShell.InvocationStateInfo.State; if (ex != null && !(ex is PipelineStoppedException)) { ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), ex.ToString()); if (!(ex is CmdletInvocationException)) { int innerErrorCode = LocalizedException.GenerateErrorCode(ex); ex = new CommandExecutionException(innerErrorCode, this.Command.ToString(), ex); } this.InteractionHandler.ReportException(ex); throw ex; } if (this.LastUnhandledError != null) { throw new MonadDataAdapterInvocationException(this.LastUnhandledError, this.Command.ToString()); } ExTraceGlobals.IntegrationTracer.Information((long)this.GetHashCode(), "<--MonadCommand.ClosePipeline()"); return(result); }