コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionInfo"/> class.
        /// </summary>
        /// <param name="ex">The ex.</param>
        public ExceptionInfo(Exception ex)
            : this()
        {
            this.MainMessage = Translatables.ERROR_UNHANDLED_EX;
            this.Description = ex.Message;

            // Read all available analyzers
            List <IExceptionAnalyzer> exceptionAnalyzer =
                SeeingSharpApplication.Current.TypeQuery.GetAndInstanciateByContract <IExceptionAnalyzer>();

            // Analyze the given exception
            ExceptionInfoNode newNode = new ExceptionInfoNode(ex);

            m_childNodes.Add(newNode);
            AnalyzeException(ex, newNode, exceptionAnalyzer);
        }
コード例 #2
0
        /// <summary>
        /// Analyzes the given exception.
        /// </summary>
        /// <param name="ex">The exception to be analyzed.</param>
        /// <param name="targetNode">The target node where to put all data to.</param>
        /// <param name="exceptionAnalyzers">All loaded analyzer objects.</param>
        private void AnalyzeException(Exception ex, ExceptionInfoNode targetNode, IEnumerable <IExceptionAnalyzer> exceptionAnalyzers)
        {
            // Query over all exception data
            foreach (IExceptionAnalyzer actAnalyzer in exceptionAnalyzers)
            {
                // Read all properties of the current exception
                foreach (ExceptionProperty actProperty in actAnalyzer.ReadExceptionInfo(ex))
                {
                    if (actProperty == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(actProperty.Name))
                    {
                        continue;
                    }

                    ExceptionInfoNode propertyNode = new ExceptionInfoNode(actProperty);
                    targetNode.ChildNodes.Add(propertyNode);
                }

                // Read all inner exception information
                foreach (Exception actInnerException in actAnalyzer.GetInnerExceptions(ex))
                {
                    if (actInnerException == null)
                    {
                        continue;
                    }

                    ExceptionInfoNode actInfoNode = new ExceptionInfoNode(actInnerException);
                    AnalyzeException(actInnerException, actInfoNode, exceptionAnalyzers);
                    targetNode.ChildNodes.Add(actInfoNode);
                }
            }

            // Sort all generated nodes
            targetNode.ChildNodes.Sort();
        }