コード例 #1
0
ファイル: ServiceFault.cs プロジェクト: xiaopohou/Topshelf
        void RecordInnerException(Exception ex)
        {
            if (ex == null)
            {
                return;
            }

            InnerExceptions.Add(DetailsFor(ex));
            RecordInnerException(ex.InnerException);
        }
コード例 #2
0
ファイル: ServiceFault.cs プロジェクト: haf/Topshelf
        void RecordInnerException(Exception ex)
        {
            if (ex == null)
            {
                return;
            }

            InnerExceptions.Add(new ExceptionDetail
            {
                Message    = ex.Message,
                StackTrace = ex.StackTrace
            });

            RecordInnerException(ex.InnerException);
        }
コード例 #3
0
        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));
                }
            }
        }
コード例 #4
0
 /// <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);