Error Record Interface
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Implemented by exception classes which contain additional ErrorRecord information.
public interface class IContainsErrorRecord
public interface IContainsErrorRecord
type IContainsErrorRecord = interface
Public Interface IContainsErrorRecord
MSH defines certain exception classes which implement this interface. This includes wrapper exceptions such as CmdletInvocationException, and also MSH engine errors such as GetValueException. Cmdlets and providers should not define this interface; instead, they should use the WriteError(ErrorRecord) or ThrowTerminatingError(ErrorRecord) methods. The ErrorRecord property will contain an ErrorRecord which contains an instance of ParentContainsErrorRecordException rather than the actual exception.
Do not call WriteError(e.ErrorRecord). The ErrorRecord contained in the ErrorRecord property of an exception which implements IContainsErrorRecord should not be passed directly to WriteError, since it contains a ParentContainsErrorRecordException rather than the real exception.
It is permitted for PSSnapins to implement custom Exception classes which implement IContainsErrorRecord, but it is generally preferable for Cmdlets and CmdletProviders to communicate ErrorRecord information using ThrowTerminatingError(ErrorRecord) or ThrowTerminatingError(ErrorRecord) rather than by throwing an exception which implements IContainsErrorRecord. Consider implementing in your custom exception only if you throw it from a context where a reference to the active or is no longer available.
This is the ErrorRecord which provides additional information about the error.