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(); } }
/// <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(); } }