Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ErrorRecord Class

Definition

Namespace:
System.Management.Automation
Assembly:
System.Management.Automation.dll
Package:
Microsoft.PowerShell.5.1.ReferenceAssemblies v1.0.0
Package:
System.Management.Automation v7.4.15
Package:
System.Management.Automation v7.5.6
Package:
System.Management.Automation v7.6.1

Important

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.

Represents an error.

public ref class ErrorRecord : System::Runtime::Serialization::ISerializable
[System.Serializable]
public class ErrorRecord : System.Runtime.Serialization.ISerializable
public class ErrorRecord : System.Runtime.Serialization.ISerializable
[<System.Serializable>]
type ErrorRecord = class
 interface ISerializable
type ErrorRecord = class
 interface ISerializable
Public Class ErrorRecord
Implements ISerializable
Inheritance
ErrorRecord
Derived
Attributes
Implements

Remarks

An ErrorRecord describes an error. It extends the usual information in Exception with the additional information in ErrorDetails, TargetObject, CategoryInfo, FullyQualifiedErrorId, ErrorDetails, and InvocationInfo. Non-terminating errors are stored as ErrorRecord instances in shell variable $error.

Some terminating errors implement IContainsErrorRecord which gives them an ErrorRecord property containing this additional information. In this case, ErrorRecord.Exception will be an instance of ParentContainsErrorRecordException. rather than the actual exception, to avoid the mutual references.

Constructors

Name Description
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(Exception, String, ErrorCategory, Object)

Creates an instance of ErrorRecord.

ErrorRecord(SerializationInfo, StreamingContext)

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

Properties

Name Description
CategoryInfo

Information regarding the ErrorCategory associated with this error, and with the categorized error message for that ErrorCategory.

ErrorDetails

Additional information about the error.

Exception

An Exception describing the error.

FullyQualifiedErrorId

String which uniquely identifies this error condition.

InvocationInfo

Identifies the cmdlet, script, or other command which caused the error.

PipelineIterationInfo

The status of the pipeline when this record was created.

ScriptStackTrace

The script stack trace for the error.

TargetObject

The object against which the error occurred.

Methods

Name Description
GetObjectData(SerializationInfo, StreamingContext)

Deserializer for ISerializable

ToString()

As ToString()

Applies to