コード例 #1
0
        public static ErrorReportDTO GenerateReport(IErrorReporterContext context)
        {
            ErrorReportDTO dto = OneTrue.GenerateReport(context);

            return(dto);
        }
コード例 #2
0
        /// <summary>
        ///     Do the OneTrueError collection pipeline.
        /// </summary>
        /// <param name="source">Thingy that detected the exception</param>
        /// <param name="exception">Exception that was caught</param>
        /// <param name="httpContext">Context currently executing</param>
        /// <param name="contextCollections">Extras</param>
        public static void ExecutePipeline(object source, Exception exception, HttpContextBase httpContext,
                                           params ContextCollectionDTO[] contextCollections)
        {
            if (
                httpContext.Request.Url.AbsolutePath.IndexOf("/onetrueerror/submit", StringComparison.OrdinalIgnoreCase) !=
                -1)
            {
                ProcessSubmit(httpContext);
                httpContext.Response.Redirect("~/");
                return;
            }

            HttpApplication application = null;
            var             module      = source as ErrorHttpModule;

            if (module != null && module.Application != null)
            {
                application = module.Application;
                if (DisplayErrorPage)
                {
                    module.Application.Response.Clear();
                }
            }

            var httpCodeIdentifier = new HttpCodeIdentifier(application, exception);
            var reportingContext   = new AspNetContext(application ?? source, exception, httpContext);
            var report             = OneTrue.GenerateReport(reportingContext);

            if (contextCollections.Any())
            {
                var newList = new List <ContextCollectionDTO>(report.ContextCollections);
                newList.AddRange(contextCollections);
                report.ContextCollections = newList.ToArray();
            }

            // Add http code
            var exceptionCollection = report.ContextCollections.FirstOrDefault(x => x.Name == "ExceptionProperties");

            if (exceptionCollection != null)
            {
                if (!exceptionCollection.Properties.ContainsKey("HttpCode"))
                {
                    exceptionCollection.Properties["HttpCode"] = httpCodeIdentifier.HttpCode.ToString();
                }
            }

            if (!DisplayErrorPage || !OneTrue.Configuration.UserInteraction.AskUserForPermission)
            {
                OneTrue.UploadReport(report);
                if (!DisplayErrorPage)
                {
                    return;
                }
            }
            else
            {
                TempData[report.ReportId] = report;
            }

            var handler = new CustomControllerContext(exception, report.ReportId)
            {
                HttpCode     = httpCodeIdentifier.HttpCode,
                HttpCodeName = httpCodeIdentifier.HttpCodeName
            };

            var ctx = new HttpErrorReporterContext(source, exception, httpContext)
            {
                ErrorId            = report.ReportId,
                HttpStatusCode     = handler.HttpCode,
                HttpStatusCodeName = handler.HttpCodeName
            };

            httpContext.Response.StatusCode        = handler.HttpCode;
            httpContext.Response.StatusDescription = handler.HttpCodeName;
            handler.Execute(ctx);
        }
コード例 #3
0
        public static ErrorReportDTO GenerateReport(Exception exception)
        {
            ErrorReportDTO dto = OneTrue.GenerateReport(exception);

            return(dto);
        }