Error Manager (.NET)

The Error Manager API exposes a single endpoint for creating errors, which can be displayed in the Error tab in Relativity.

You can also interact with the Error Manager API through the REST API. See Error Manager service.

Guidelines for Error Manager API

Review the following guidelines for working with this service.

  • Set {versionNumber} to the version of the API, using the format lowercase v and the version number, such as v1.

Fundamentals for using Error Manager

Key concepts or other explanatory information

Review the following information to learn about the methods, classes, and other entities used by the Agent Manager service.

The Relativity.Environment.{versionNumber}.Error namespace contains the IErrorManager interface that exposes the following methods:

  • CreateAsync() method - adds a new error log to a database. It returns the Artifact ID of the new error log.

The Relativity.Environment.{versionNumber}.Error.Models namespace contains the following class used by the Error Manager API:

  • CreateErrorRequest class - represents information about an error log.

Guidelines or best practices

  • To set up a proxy to interact with the Error Manager API, call the CreateProxy() method on the object returned by the GetServiceManager() method.
  • If you plan to use Error Manager API using the IErrorManager interface in your RAP application, remember to add the Relativity.Environment.SDK package to your RAP definition.
  • In order to use Error Manager endpoints, you need to import the Relativity.Environment.SDK package. The Error Manager interface is found under the Relativity.Environment.{versionNumber}.Error namespace.
  • Every Error log has its own ArtifactID (returned as a response of CreateAsync() method), enabling you to easily find it on the Error tab.

Create an error log

Create the CreateErrorRequest object and pass it through IErrorManager.CreateAsync() method.

Note: Please remember that all properties except Message are optional. The method returns single integer.

Create an error log using service manager (recommended)

Copy
using Relativity.Environment.{versionNumber}.Error;
using Relativity.Environment.{versionNumber}.Error.Models;
    
Client.SamplesLibrary.Helper.IHelper helper;
    
// Create a proxy
using (IErrorManager errorManager = helper.GetServicesManager().CreateProxy<IErrorManager>(ExecutionIdentity.User))
{
    var createErrorRequest = new CreateErrorRequest
        {
            Message = "Single line message",
            FullError = "Detailed error message", // exception.ToString()
            Server = System.Environment.MachineName,
            Source = "Name of my agent",
            StepsToReproduce = string.Empty,
            URL = "URL to your custom page or kepler",
            Workspace = new ObjectIdentifier { ArtifactID = -1 },
        };
    int errorLogArtifactID = errorManager.CreateAsync(createErrorRequest);
}

You can also use an HttpClient directly if you do not use the Relativity.Environment.SDK nuget package.

Create an error log using an HTTP client

Copy
using System.Net.Http;
using Newtonsoft.Json;
 
private HttpClient GetHttpClient()
{
    HttpClient httpClient = new HttpClient();
 
    httpClient.BaseAddress = new Uri("https://localhost/");
    httpClient.DefaultRequestHeaders.Add("X-CSRF-Header", "-");
    httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " +
        Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes("test@test.com:SomePassword")));
 
    return httpClient;
}
 
const string errorManagerEndpoint = "Relativity.Rest/api/relativity-environment/{versionNumber}/workspaces/-1/errors";
 
var payloadObject = new
{
    createErrorRequest = new
    {
        Message = "Single line message",
        FullError = "Detailed error message", // exception.ToString()
        Server = System.Environment.MachineName,
        Source = "Name of my agent",
        StepsToReproduce = string.Empty,
        URL = "URL to your custom page or kepler",
        Workspace = new
        {
            ArtifactID = -1
        }
    }
};
 
StringContent payload = new StringContent(JsonConvert.SerializeObject(payloadObject), Encoding.UTF8, "application/json");
HttpResponseMessage response = await GetHttpClient().PostAsync(errorManagerEndpoint, payload);
 
string responseMessage = await response.Content.ReadAsStringAsync();
int artifactID = Convert.ToInt32(responseMessage);