<PackageReference Include="Relativity.Server.Import.SDK" Version="2.9.2" />

KeplerExceptionDetail

public class KeplerExceptionDetail
Represents the SoapException detail property extracted from Kepler ServiceException message. Please also refer SoapExceptionDetail
using Microsoft.VisualBasic.CompilerServices; using Relativity.DataExchange.Logger; using Relativity.Logging; using System; using System.Runtime.CompilerServices; using System.Xml.Serialization; namespace kCura.WinEDDS.Mapping { [Serializable] [XmlType("SoapExceptionDetail")] [XmlRoot(ElementName = "detail")] public class KeplerExceptionDetail { private const string ExceptionTypeKey = "InnerExceptionType:"; private const string ExceptionMessageKey = "InnerExceptionMessage:"; private const string ExceptionMessageValuePrefix = "Error:"; private const char KeyValuePairSeparator = ','; private readonly ILog _logger; [CompilerGenerated] private string _ExceptionType; [CompilerGenerated] private string _ExceptionMessage; [CompilerGenerated] private string _ExceptionFullText; [XmlElement("ExceptionType")] public string ExceptionType { get; set; } [XmlElement("ExceptionMessage")] public string ExceptionMessage { get; set; } [XmlElement("ExceptionFullText")] public string ExceptionFullText { get; set; } public KeplerExceptionDetail() { _logger = RelativityLogger.Instance; } public KeplerExceptionDetail(Exception exception) { _logger = RelativityLogger.Instance; ExtractDetailsFromException(exception); } private void ExtractDetailsFromException(Exception exception) { try { SetDetailsFromException(exception); if (ShouldParseExceptionMessage(exception)) SetDetailsFromExceptionMessage(exception); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception ex2 = ex; _logger.LogError(ex2, "Error when parsing Kepler error message - {ExceptionMessage}. Kepler error message: {KeplerExceptionMessage}", new object[2] { ex2.Message, exception.Message }); ProjectData.ClearProjectError(); } } private bool ShouldParseExceptionMessage(Exception exception) { if (!string.IsNullOrWhiteSpace(exception?.Message)) { int num = exception.Message.IndexOf("InnerExceptionType:", StringComparison.OrdinalIgnoreCase); int num2 = exception.Message.IndexOf("InnerExceptionMessage:", StringComparison.OrdinalIgnoreCase); if (!((num == -1) | (num2 == -1))) return true; return false; } return false; } private void SetDetailsFromException(Exception exception) { if (exception == null) { ExceptionType = string.Empty; ExceptionMessage = string.Empty; ExceptionFullText = string.Empty; } else { ExceptionType = exception.GetType().FullName; ExceptionMessage = exception.Message?.Trim(); ExceptionFullText = ExceptionMessage; } } private void SetDetailsFromExceptionMessage(Exception exception) { int num = exception.Message.IndexOf("InnerExceptionType:", StringComparison.OrdinalIgnoreCase); int num2 = exception.Message.IndexOf("InnerExceptionMessage:", StringComparison.OrdinalIgnoreCase); ExceptionType = ExtractKeyValueFromText(exception.Message, num, "InnerExceptionType:".Length, num2, null); ExceptionMessage = ExtractKeyValueFromText(exception.Message, num2, "InnerExceptionMessage:".Length, num, "Error:"); ExceptionFullText = ExceptionMessage; } private string ExtractKeyValueFromText(string inputText, int keyIndex, int keyLength, int endIndex, string valuePrefix = null) { if (keyIndex != -1) { string inputText2 = checked((endIndex >= keyIndex) ? inputText.Substring(keyIndex + keyLength, endIndex - keyIndex - keyLength).Trim() : inputText.Substring(keyIndex + keyLength).Trim()); RemoveLastCharacter(ref inputText2, ','); AppendPrefix(ref inputText2, valuePrefix); return inputText2.Trim(); } return string.Empty; } private void RemoveLastCharacter(ref string inputText, char lastCharToRemove) { checked { if (!string.IsNullOrEmpty(inputText) && inputText[inputText.Length - 1] == lastCharToRemove) inputText = inputText.Remove(inputText.Length - 1, 1); } } private void AppendPrefix(ref string inputText, string prefix) { if (!string.IsNullOrWhiteSpace(inputText) && !string.IsNullOrWhiteSpace(prefix)) inputText = prefix + " " + inputText; } } }