ExceptionDispatchInfo.Capture(Exception) Method

Definition

Creates an ExceptionDispatchInfo object that represents the specified exception at the current point in code.

public:
 static System::Runtime::ExceptionServices::ExceptionDispatchInfo ^ Capture(Exception ^ source);
public static System.Runtime.ExceptionServices.ExceptionDispatchInfo Capture (Exception source);
static member Capture : Exception -> System.Runtime.ExceptionServices.ExceptionDispatchInfo
Public Shared Function Capture (source As Exception) As ExceptionDispatchInfo

Parameters

source
Exception

The exception whose state is captured, and which is represented by the returned object.

Returns

An object that represents the specified exception at the current point in code.

Exceptions

source is null.

Remarks

You can use the ExceptionDispatchInfo object that's returned by this method at another time and possibly on another thread to rethrow the specified exception, as if the exception had flowed from the point where it was captured to the point where it's rethrown.

If the exception is active when it's captured, the current stack trace information and Watson information that's contained in the exception is stored. If it's inactive, that is, if it has not been thrown, it doesn't have any stack trace or Watson information.

Applies to

See also