ExceptionExtensions.AddData<T>(T, String, Object[]) Method

Definition

Adds data to the Data member of exception before returning the modified exception.

public:
generic <typename T>
 where T : Exception[System::Runtime::CompilerServices::Extension]
 static T AddData(T exception, System::String ^ key, ... cli::array <System::Object ^> ^ values);
public static T AddData<T> (this T exception, string key, params object[]? values) where T : Exception;
static member AddData : 'T * string * obj[] -> 'T (requires 'T :> Exception)
<Extension()>
Public Function AddData(Of T As Exception) (exception As T, key As String, ParamArray values As Object()) As T

Type Parameters

T

The type of exception being modified.

Parameters

exception
T

The exception to add data to.

key
String

The key to use for the added data.

values
Object[]

The values to add with the given key.

Returns

T

A reference to the same exception.

Remarks

This method should be used to add context (beyond the message and callstack we normally get) to the exception that would be useful when debugging Watson crashes.

Do not use this method when you expect the exception to be handled.

Applies to