SharpRaven.Data.JsonPacket.Initialize C# (CSharp) Method

Initialize() private method

private Initialize ( Exception exception ) : void
exception System.Exception
return void
        private void Initialize(Exception exception)
        {
            Message = exception.Message;

            if (exception.TargetSite != null)
            {
                // ReSharper disable ConditionIsAlwaysTrueOrFalse => not for dynamic types.
                Culprit = String.Format("{0} in {1}",
                                        ((exception.TargetSite.ReflectedType == null)
                                            ? "<dynamic type>"
                                            : exception.TargetSite.ReflectedType.FullName),
                                        exception.TargetSite.Name);
                // ReSharper restore ConditionIsAlwaysTrueOrFalse
            }

            Exceptions = new List<SentryException>();

            for (Exception currentException = exception;
                currentException != null;
                currentException = currentException.InnerException)
            {
                SentryException sentryException = new SentryException(currentException)
                {
                    Module = currentException.Source,
                    Type = currentException.GetType().Name,
                    Value = currentException.Message
                };

                Exceptions.Add(sentryException);
            }

            // ReflectionTypeLoadException doesn't contain much useful info in itself, and needs special handling
            ReflectionTypeLoadException reflectionTypeLoadException = exception as ReflectionTypeLoadException;
            if (reflectionTypeLoadException != null)
            {
                foreach (Exception loaderException in reflectionTypeLoadException.LoaderExceptions)
                {
                    SentryException sentryException = new SentryException(loaderException);

                    Exceptions.Add(sentryException);
                }
            }
        }