Non-Terminating Errors

This topic discusses the method used to report non-terminating errors. It also discusses how to call the method from within the cmdlet.

When a non-terminating error occurs, the cmdlet should report this error by calling the System.Management.Automation.Cmdlet.WriteError method. When the cmdlet reports a non-terminating error, the cmdlet can continue to operate on this input object and on further incoming pipeline objects. If the cmdlet calls the System.Management.Automation.Cmdlet.WriteError method, the cmdlet can write an error record that describes the condition that caused the non-terminating error. For more information about error records, see Windows PowerShell Error Records.

Cmdlets can call System.Management.Automation.Cmdlet.WriteError as necessary from within their input processing methods. However, cmdlets can call System.Management.Automation.Cmdlet.WriteError only from the thread that called the System.Management.Automation.Cmdlet.BeginProcessing, System.Management.Automation.Cmdlet.ProcessRecord, or System.Management.Automation.Cmdlet.EndProcessing input processing method. Do not call System.Management.Automation.Cmdlet.WriteError from another thread. Instead, communicate errors back to the main thread.

See Also





Windows PowerShell Error Records

Writing a Windows PowerShell Cmdlet