IContainsErrorRecord Interface


Updated: April 27, 2016

Applies To: Windows PowerShell

Provides a mechanism for adding an error record to an exception.

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

public interface class IContainsErrorRecord


Gets the error record that describes the error that occurred.

Windows PowerShell defines certain exception classes that implement this interface. This includes wrapper exceptions such as System.Management.Automation::CmdletInvocationException and Windows PowerShell runtime exceptions such as System.Management.Automation::GetValueException.

This interface should be implemented only when the exception is thrown when there is no reference to an active cmdlet or provider.

This interface should not be implemented by cmdlets and providers. Instead, cmdlets and providers should call the following methods.

For cmdlets, call one of the following methods:

For providers, call one of the following methods.

Windows PowerShell snap-ins can implement custom exception classes that implement IContainsErrorRecord. However, it is generally preferable for cmdlets and providers to communicate error records using the methods listed previously, rather than the snap-in throwing an exception that implements IContainsErrorRecord.

Return to top