private void Initialize(Exception exception, IEnumerable <Exception> innerExceptions, bool isWarning) { ExceptionType = exception.GetType().FullName; try { Source = exception.Source; } catch { } try { StackTrace = exception.StackTrace; } catch { } try { TargetSite = exception.TargetSite.ToString(); } catch { } foreach (Exception exc in innerExceptions) { if (exc is AggregateException) { InnerInnerErrors.Add(new ExceptionMessageVM(exc as AggregateException, isWarning)); } else if (exc is XmlException) { InnerInnerErrors.Add(new XmlValidationMessageVM(exc as XmlException, isWarning)); } else if (exc is XmlSchemaException) { InnerInnerErrors.Add(new XmlValidationMessageVM(exc as XmlSchemaException, isWarning)); } else { InnerInnerErrors.Add(new ExceptionMessageVM(exc, isWarning)); } } }
public void UpdateFrom(string message, Exception exception, bool isWarning) { UpdateFrom((String.IsNullOrEmpty(message)) ? ((exception == null) ? null : exception.Message) : message, isWarning); InnerInnerErrors.Clear(); if (exception != null) { Initialize(exception, (exception.InnerException == null) ? new Exception[0] : new Exception[] { exception.InnerException }, isWarning); } }