Beispiel #1
0
        /// <summary>
        ///     Build an report, but do not upload it
        /// </summary>
        /// <param name="context">
        ///     context passed to all context providers when collecting information. This context is typically
        ///     implemented by one of the integration libraries to provide more context that can be used to process the
        ///     environment.
        /// </param>
        /// <remarks>
        ///     <para>
        ///         Will collect context info and generate a report.
        ///     </para>
        /// </remarks>
        /// <exception cref="ArgumentNullException">exception;contextData</exception>
        public ErrorReportDTO Build(IErrorReporterContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (context.Exception is CoderrClientException)
            {
                return(null);
            }
            if (IsReported(context.Exception))
            {
                return(null);
            }
            ErrorReporterContext.MoveCollectionsInException(context.Exception, context.ContextCollections);
            InvokePreProcessor(context);

            _configuration.ContextProviders.Collect(context);

            // Invoke partition collection AFTER other context info providers
            // since those other collections might provide the property that
            // we want to create partions on.
            InvokePartitionCollection(context);

            var reportId = ReportIdGenerator.Generate(context.Exception);

            AddAddemblyVersion(context.ContextCollections);
            var report = new ErrorReportDTO(reportId, new ExceptionDTO(context.Exception),
                                            context.ContextCollections.ToArray());

            return(report);
        }
        /// <summary>
        ///     Process exception.
        /// </summary>
        /// <param name="context">
        ///     Used to reports (like for ASP.NET) can attach information which can be used during the context
        ///     collection pipeline.
        /// </param>
        /// <remarks>
        ///     <para>
        ///         Will collect context info, generate a report, go through filters and finally upload it.
        ///     </para>
        /// </remarks>
        /// <returns>
        ///     Report if filter allowed the generated report; otherwise <c>null</c>.
        /// </returns>
        /// <seealso cref="IReportFilter" />
        public ErrorReportDTO Build(IErrorReporterContext context)
        {
            if (context.Exception is CoderrClientException)
            {
                return(null);
            }
            if (context.Exception.Data.Contains(AlreadyReportedSetting))
            {
                return(null);
            }
            context.Exception.Data.Add(AlreadyReportedSetting, true);

            if (context is IErrorReporterContext2 ctx2)
            {
                ErrorReporterContext.MoveCollectionsInException(context.Exception, ctx2.ContextCollections);
                InvokeFilter(ctx2);
            }


            var contextInfo = _configuration.ContextProviders.Collect(context);

            // Invoke partition collection AFTER other context info providers
            // since those other collections might provide the property that
            // we want to create partions on.
            InvokePartitionCollection(context);

            MoveCollectionsFromContext(context, contextInfo);
            var reportId = ReportIdGenerator.Generate(context.Exception);

            AddAddemblyVersion(contextInfo);
            var report =
                new ErrorReportDTO(reportId, new ExceptionDTO(context.Exception), contextInfo.ToArray())
            {
                Environment = Err.Configuration.EnvironmentName
            };

            return(report);
        }