Share via


How to Retrieve Individual File Replication Errors

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

You use the CReplicationClient.GetExtendedErrorInfo method to retrieve errors associated with individual file replication operations. This method only returns errors associated with replication destinations. It does not return other errors, such as invalid parameter errors or object not initialized.

To retrieve individual file replication errors

  1. Invoke or initiate a CReplicationClient object. For information about how to invoke this object, see How to Replicate Individual Files.

  2. After you send or delete files, specify to catch system runtime interop services errors.

  3. Retrieve the errors, if any, by calling the CReplicationClient.GetExtendedErrorInfo method. This will populate an array with a CReplicationClientError object for each destination server that is defined for the project that you used in step 1. The array is empty if no errors occurred.

  4. List or write the error information that is for a file. The following information is available for each CReplicationClientError object:

    • Description. A textual description of an error.

    • Destination. The destination server where the error occurred.

    • ErrorCode. The CSS or system error code.

    • FileName. The file name associated with the error.

    • Project. The project for which the error occurred.

    • Source. The source server for the individual file replication.

Example

The following example tries to send a file that is named myfile.htm. If any errors occur, it displays the following information:

  • Name of the source staging server.

  • Name of the destination server where the error occurred.

  • Name of the project providing the client replication context.

  • Name of the file that encountered the error.

  • Error code of the error encountered.

  • Description of the error code.

CReplicationClient replicationClient = new CReplicationClient();
replicationClient.Initialize("Project1");
try
{
    replicationClient.SendFile("myfile.htm");
}
catch (System.Runtime.InteropServices.COMException)
{
    object[] errors = (object[])replicationClient.GetExtendedErrorInfo();
    // If the ClientError array is not empty, loop through it and display each error
    int numElements = errors.Length;
    if (numElements > 0)
    {
        Console.WriteLine("Could not send file to destination(s):");
        for (int i = 0; i < numElements; i++)
        {
          Console.WriteLine("Source: {0}", ((CReplicationClientError)errors[i]).get_Source());
          Console.WriteLine("Destination: {0}", ((CReplicationClientError)errors[i]).get_Destination());
          Console.WriteLine("Project: {0}", ((CReplicationClientError)errors[i]).get_Project());
            Console.WriteLine("File: {0}", ((CReplicationClientError)errors[i]).get_FileName());
          Console.WriteLine("Error code: {0}", ((CReplicationClientError)errors[i]).get_ErrorCode());
          Console.WriteLine("Description code: {0}", ((CReplicationClientError)errors[i]).get_Description());
        }
    }
}

See Also

Other Resources

Projects

Individual File Replications

CReplicationClient Class

CReplicationClient Class

CSS API Error Handling

Replicating Individual Files by using the Staging API