Esempio n. 1
0
        /// <summary>
        /// Converts an <see cref="Exception"/> to <see cref="ExceptionModel"/>
        /// and <see cref="FrameModel"/>[] and wraps them in a <see cref="TraceModel"/>
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static TraceModel CreateFromException(Exception exception)
        {
            var exceptionModel = ExceptionModelBuilder.CreateFromException(exception);
            var frames         = FrameModelBuilder.CreateFramesFromException(exception);

            return(new TraceModel(exceptionModel, frames));
        }
        /// <summary>
        /// Converts an <see cref="Exception"/> ands his InnerExceptions to
        /// <see cref="TraceModel"/>'s.
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static IEnumerable <TraceModel> CreateFromException(Exception exception)
        {
            var traces  = new List <TraceModel>();
            var innerEx = exception;

            while (innerEx != null)
            {
                var exceptionModel = ExceptionModelBuilder.CreateFromException(innerEx);
                var frames         = FrameModelBuilder.CreateFramesFromException(innerEx);

                traces.Insert(0, new TraceModel(exceptionModel, frames));

                innerEx = innerEx.InnerException;
            }

            return(traces);
        }