This DTO has been deprecated as part of the Relativity Services API (RSAPI) Deprecation and is no longer supported. For more information and alternative APIs, see RSAPI deprecation process.

Error

The Services API provides an Error DTO, which represents an exception thrown in Relativity. The Services API supports only the create operation on an Error DTO. For more information, see the RelativityOne Documentation site.

Write to the error log

You can write an entry to the Relativity error log using the Create() method on the RSAPIClient proxy. This method takes an ArtifactRequest parameter with the ArtifactTypeName set to Error or the ArtifactTypeID set to 18. The Fields collection provides the field values to set on the newly created Error object. The Message or Full Error field is required.

When you call the Create() method, the value set in the Workspace on the APIOptions object affects the information added to the error log :

  • If Workspace is set to -1, the error log creates an error but not associate it with a specific workspace.
  • If Workspace is set to valid ID for a workspace, the error log automatically creates an error associated with that workspace.
  • If you pass a new field named Workspace with a valid ID for a workspace (overriding the field in the APIOptions object), the error log creates an error associated with the workspace specified by this field.

The following sample code illustrates how to write errors to the Relativity error log.

public static bool Create_Error_Message(IRSAPIClient proxy)
{
     // STEP 1: Create an Error DTO.
     DTOs.Error errorToCreate = new DTOs.Error();
      
     // STEP 2: Create a unexpected condition which throws an exception.
     try
     {
          throw new Exception("Invalid Data");
     }
     catch (Exception ex)
     {
          errorToCreate.FullError = ex.StackTrace;
          errorToCreate.Message = ex.Message;
     }
      
     // Set additional fields. The Workspace can be inferred from the APIOptions instance.
     errorToCreate.SendNotification = false;
     errorToCreate.Server = Environment.MachineName;
     errorToCreate.Source = "3rd Party Application";
     errorToCreate.URL = "https://url/to/relativity/page.aspx";
     errorToCreate.Workspace = new DTOs.Workspace(1016204);
      
     //STEP 3: Attempt to create the error.
            
     DTOs.WriteResultSet<DTOs.Error> resultSet = null;
     try
     {
          resultSet = proxy.Repositories.Error.Create(errorToCreate);
     }
     catch (Exception ex)
     {
          Console.WriteLine("An error occurred: {0}", ex.Message);
          return false;
     }
      
     //STEP 4: Check for success.
     if (resultSet.Success)
     {
          Console.WriteLine("Error Message successfully written to Relativity Error Log");
     }
     else
     {
          Console.WriteLine("Error Message not written to Relativity Error Log");
          return false;
     }
     return true;
}
        

Note: You can also write to the error log using the CreateSingle method. For more information, see Single-artifact access.

Additional Resources

DevHelp Community GitHub Release Notes NuGet

Share knowledge with the Relativity developer community.

Access tools and resources to build an application.

Review the most recent product release notes.

Create .NET Apps faster with NuGet.