Share via


ErrorRecord Constructors

Definition

Overloads

ErrorRecord(ErrorRecord, Exception)

Copy constructor, for use when a new wrapper exception wraps an exception which already has an ErrorRecord ErrorCategoryInfo and ErrorDetails are deep-copied, other fields are not.

ErrorRecord(SerializationInfo, StreamingContext)

Initializes a new instance of the ErrorRecord class using data serialized via ISerializable

ErrorRecord(Exception, String, ErrorCategory, Object)

Creates an instance of ErrorRecord.

ErrorRecord(ErrorRecord, Exception)

Copy constructor, for use when a new wrapper exception wraps an exception which already has an ErrorRecord ErrorCategoryInfo and ErrorDetails are deep-copied, other fields are not.

public:
 ErrorRecord(System::Management::Automation::ErrorRecord ^ errorRecord, Exception ^ replaceParentContainsErrorRecordException);
public ErrorRecord (System.Management.Automation.ErrorRecord errorRecord, Exception replaceParentContainsErrorRecordException);
new System.Management.Automation.ErrorRecord : System.Management.Automation.ErrorRecord * Exception -> System.Management.Automation.ErrorRecord
Public Sub New (errorRecord As ErrorRecord, replaceParentContainsErrorRecordException As Exception)

Parameters

errorRecord
ErrorRecord

Wrapped ErrorRecord.

replaceParentContainsErrorRecordException
Exception

If the wrapped exception contains a ParentContainsErrorRecordException, the new ErrorRecord should have this exception as its Exception instead.

Applies to

ErrorRecord(SerializationInfo, StreamingContext)

Initializes a new instance of the ErrorRecord class using data serialized via ISerializable

protected:
 ErrorRecord(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected ErrorRecord (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Management.Automation.ErrorRecord : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Management.Automation.ErrorRecord
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameters

info
SerializationInfo

Serialization information.

context
StreamingContext

Streaming context.

Remarks

ErrorRecord instances which are serialized using ISerializable will only be partially reconstructed.

Applies to

ErrorRecord(Exception, String, ErrorCategory, Object)

Creates an instance of ErrorRecord.

public:
 ErrorRecord(Exception ^ exception, System::String ^ errorId, System::Management::Automation::ErrorCategory errorCategory, System::Object ^ targetObject);
public ErrorRecord (Exception exception, string errorId, System.Management.Automation.ErrorCategory errorCategory, object targetObject);
new System.Management.Automation.ErrorRecord : Exception * string * System.Management.Automation.ErrorCategory * obj -> System.Management.Automation.ErrorRecord
Public Sub New (exception As Exception, errorId As String, errorCategory As ErrorCategory, targetObject As Object)

Parameters

exception
Exception

This is an exception which describes the error. This argument may not be null, but it is not required that the exception have ever been thrown.

errorId
String

This string will be used to construct the FullyQualifiedErrorId, which is a global identifier of the error condition. Pass a non-empty string which is specific to this error condition in this context.

errorCategory
ErrorCategory

This is the ErrorCategory which best describes the error.

targetObject
Object

This is the object against which the cmdlet or provider was operating when the error occurred. This is optional.

Applies to