SoapExceptionDetail
Represents a Relativity SOAP-based exception detail data object. This class cannot be inherited, backwards compatibility isn't guaranteed, and should never be consumed by API users.
using System;
using System.Text;
using System.Xml.Serialization;
namespace Relativity.DataExchange.Service
{
[Serializable]
[XmlType("SoapExceptionDetail")]
[XmlRoot(ElementName = "detail")]
public sealed class SoapExceptionDetail
{
[XmlElement("Details")]
public string[] Details { get; set; }
[XmlElement("ExceptionFullText")]
public string ExceptionFullText { get; set; }
[XmlElement("ExceptionMessage")]
public string ExceptionMessage { get; set; }
[XmlElement("ExceptionTrace")]
public string ExceptionTrace { get; set; }
[XmlElement("ExceptionType")]
public string ExceptionType { get; set; }
public SoapExceptionDetail()
{
}
public SoapExceptionDetail(Exception ex)
{
if (ex == null)
throw new ArgumentNullException("ex");
ExceptionType = ex.GetType().ToString();
SetMessageText(ex);
ExceptionTrace = ex.StackTrace;
ExceptionFullText = ex.ToString();
}
private void SetMessageText(Exception ex)
{
StringBuilder stringBuilder = new StringBuilder();
GetBaseMessageAndAllInnerMessages(ex, stringBuilder);
ExceptionMessage = stringBuilder.ToString();
}
private StringBuilder GetBaseMessageAndAllInnerMessages(Exception ex, StringBuilder sb)
{
sb.AppendLine("Error: " + ex.Message);
if (ex.InnerException != null) {
sb.AppendLine("---Additional Errors---");
GetBaseMessageAndAllInnerMessages(ex.InnerException, sb);
}
return sb;
}
}
}