void RecordInnerException(Exception ex) { if (ex == null) { return; } InnerExceptions.Add(DetailsFor(ex)); RecordInnerException(ex.InnerException); }
void RecordInnerException(Exception ex) { if (ex == null) { return; } InnerExceptions.Add(new ExceptionDetail { Message = ex.Message, StackTrace = ex.StackTrace }); RecordInnerException(ex.InnerException); }
public ExceptionInfo(Exception exception, bool isNestedException = false) { if (exception == null) { throw new ArgumentNullException(nameof(exception)); } ErrorType = exception.GetType().Name; ErrorMessage = exception.Message; if (!string.IsNullOrEmpty(exception.StackTrace)) { StackTrace stackTrace = new StackTrace(exception, true); StackTrace = stackTrace.ToString(); // Only extract the stack frames like this for the top-level exception // This is used for Xray Exception serialization if (isNestedException || stackTrace?.GetFrames() == null) { StackFrames = new StackFrameInfo[0]; } else { StackFrames = ( from sf in stackTrace.GetFrames() where sf != null select new StackFrameInfo(sf) ).ToArray(); } } if (exception.InnerException != null) { InnerException = new ExceptionInfo(exception.InnerException, true); } AggregateException aggregateException = exception as AggregateException; if (aggregateException != null && aggregateException.InnerExceptions != null) { foreach (var innerEx in aggregateException.InnerExceptions) { InnerExceptions.Add(new ExceptionInfo(innerEx, true)); } } }
/// <summary> /// Add an inner exception to the <see cref="IocContainerException.InnerExceptions"/> /// </summary> /// <param name="exception">The <see cref="ConstructorNotMatchingException"/></param> public void AddInnerException(ConstructorNotMatchingException exception) => InnerExceptions.Add(exception);