SaveChangeWithChangeUnitsContext.RecordRecoverableErrorForChangeUnit Method

Indicates that a recoverable error occurred when data for this change unit was saved to the item store.

Namespace:  Microsoft.Synchronization
Assembly:  Microsoft.Synchronization (in Microsoft.Synchronization.dll)

Syntax

'Declaration
Public Sub RecordRecoverableErrorForChangeUnit ( _
    changeUnitChange As ChangeUnitChange, _
    errorData As RecoverableErrorData _
)
'Usage
Dim instance As SaveChangeWithChangeUnitsContext
Dim changeUnitChange As ChangeUnitChange
Dim errorData As RecoverableErrorData

instance.RecordRecoverableErrorForChangeUnit(changeUnitChange, _
    errorData)
public void RecordRecoverableErrorForChangeUnit(
    ChangeUnitChange changeUnitChange,
    RecoverableErrorData errorData
)
public:
void RecordRecoverableErrorForChangeUnit(
    ChangeUnitChange^ changeUnitChange, 
    RecoverableErrorData^ errorData
)
member RecordRecoverableErrorForChangeUnit : 
        changeUnitChange:ChangeUnitChange * 
        errorData:RecoverableErrorData -> unit 
public function RecordRecoverableErrorForChangeUnit(
    changeUnitChange : ChangeUnitChange, 
    errorData : RecoverableErrorData
)

Parameters

Exceptions

Exception Condition
CreateFailuresMustBeForEntireItemException

The save action that is contained in the SaveChangeWithChangeUnitsContext object is Create. In this situation, creation of the entire item must fail.

Remarks

When this method is called, an ItemChangeUnitOverride object is added to the learned knowledge, and the change unit change will not be enumerated again for the duration of the synchronization session.

Examples

The following example tries to create or update a change unit in the destination replica. When an exception occurs, a recoverable error that contains the exception is recorded for the change unit, and synchronization continues.

Case SaveChangeAction.Create, SaveChangeAction.UpdateVersionAndData
    If True Then
        ' Update the item store and metadata store for the specified change unit.
        Try
            Dim cuData As String = DirectCast(context.ChangeData, String())(cuChange.ChangeUnitId.GetByteId())
            _ContactStore.UpdateContactFromSync(change, cuChange, cuData)
        Catch ex As Exception
            Dim errData As New RecoverableErrorData(ex)
            context.RecordRecoverableErrorForChangeUnit(cuChange, errData)
        End Try
        Exit Select
    End If
case SaveChangeAction.Create:
case SaveChangeAction.UpdateVersionAndData:
{
    // Update the item store and metadata store for the specified change unit.
    try
    {
        string cuData = ((string[])context.ChangeData)[cuChange.ChangeUnitId.GetByteId()];
        _ContactStore.UpdateContactFromSync(change, cuChange, cuData);
    }
    catch (Exception ex)
    {
        RecoverableErrorData errData = new RecoverableErrorData(ex);
        context.RecordRecoverableErrorForChangeUnit(cuChange, errData);
    }
    break;
}

See Also

Reference

SaveChangeWithChangeUnitsContext Class

Microsoft.Synchronization Namespace