Cmdlet.ThrowTerminatingError Method

Reports a terminating error when the cmdlet cannot continue, or when you do not want the cmdlet to continue to process records.


Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

'Usage
Dim instance As Cmdlet
Dim errorRecord As ErrorRecord

instance.ThrowTerminatingError(errorRecord)

public void ThrowTerminatingError (
	ErrorRecord errorRecord
)
public void ThrowTerminatingError (
	ErrorRecord errorRecord
)
public function ThrowTerminatingError (
	errorRecord : ErrorRecord
)

Parameters

errorRecord

An ErrorRecord object that describes the error condition.

When a cmdlet encounters a terminating error, call this method rather than simply throwing an exception. Calling this method allows the cmdlet to attach additional error record information that describes the condition that caused the terminating error. When this method is called, the Windows PowerShell runtime catches the error record and then starts shutting down the pipeline. For more information about error reporting and error records, see Windows PowerShell Error Reporting.

This method should not be used when errors occur where the cmdlet can continue processing records. To send error reports when nonterminating errors occur, call the WriteError method.

For more information about cmdlets, see Windows PowerShell Cmdlets.


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

 

Target Platforms

Windows Developer Preview, Windows Server Developer Preview

Send comments about this topic to Microsoft.
Show:
© 2014 Microsoft