/// <summary> /// Converts a System.Exception to a ExceptionDetails. /// </summary> internal static External.ExceptionDetails ConvertToExceptionDetails( Exception exception, External.ExceptionDetails parentExceptionDetails) { External.ExceptionDetails exceptionDetails = External.ExceptionDetails.CreateWithoutStackInfo( exception, parentExceptionDetails); if (exception.StackTrace != null) { string[] lines = exception.StackTrace.Split(new string[] { "\n" }, StringSplitOptions.None); // Adding 1 for length in lengthGetter for newline character Tuple <List <string>, bool> sanitizedTuple = SanitizeStackFrame( lines, (input, id) => input, (input) => input == null ? 0 : input.Length + 1); List <string> sanitizedStackLines = sanitizedTuple.Item1; exceptionDetails.hasFullStack = sanitizedTuple.Item2; exceptionDetails.stack = string.Join("\n", sanitizedStackLines.ToArray()); } else { exceptionDetails.hasFullStack = true; exceptionDetails.stack = string.Empty; } return(exceptionDetails); }
/// <summary> /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails. /// </summary> internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, ExceptionDetails parentExceptionDetails) { if (exception == null) { throw new ArgumentNullException("exception"); } var exceptionDetails = new External.ExceptionDetails() { id = exception.GetHashCode(), typeName = exception.GetType().FullName, message = exception.Message }; if (parentExceptionDetails != null) { exceptionDetails.outerId = parentExceptionDetails.id; } return exceptionDetails; }
/// <summary> /// Creates a new instance of ExceptionDetails from a System.Exception and a parent ExceptionDetails. /// </summary> internal static ExceptionDetails CreateWithoutStackInfo(Exception exception, ExceptionDetails parentExceptionDetails) { if (exception == null) { throw new ArgumentNullException("exception"); } var exceptionDetails = new External.ExceptionDetails() { id = exception.GetHashCode(), typeName = exception.GetType().FullName, message = exception.Message }; if (parentExceptionDetails != null) { exceptionDetails.outerId = parentExceptionDetails.id; } return(exceptionDetails); }
public ExceptionDetails GetExceptionDetails(Exception exception, ExceptionDetails parentExceptionDetails) { return ExceptionConverter.ConvertToExceptionDetails(exception, parentExceptionDetails); }