private void Context_Error(object sender, EventArgs e)
        {
            if (sender is not HttpApplication httpApplication ||
                httpApplication.Context == null ||
                httpApplication.Context.AllErrors == null ||
                httpApplication.Context.AllErrors.Length == 0
                )
            {
                return;
            }

            AggregateException exception =
                new("RollbarHttpModule's context error(s)", httpApplication.Context.AllErrors);

            IRollbarPackage package =
                new ExceptionPackage(exception, "HttpApplication.Context.AllErrors", true);

            // The HttpContext decorator already takes care of the HttpRequest and HttpResponse internally:
            package =
                new HttpContextPackageDecorator(package, httpApplication.Context);

            if (httpApplication.User?.Identity != null && !string.IsNullOrWhiteSpace(httpApplication.User.Identity.Name))
            {
                package = new PersonPackageDecorator(package, httpApplication.User.Identity.Name, httpApplication.User.Identity.Name, null);
            }

            this._rollbar.Error(package);
        }
Exemplo n.º 2
0
        private void Context_Error(object sender, EventArgs e)
        {
            HttpApplication httpApplication = sender as HttpApplication;

            if (httpApplication == null ||
                httpApplication.Context == null ||
                httpApplication.Context.AllErrors == null ||
                httpApplication.Context.AllErrors.Length == 0
                )
            {
                return;
            }

            // potential objects to snap as a Rollbar payload:
            //************************************************

            //httpApplication.Context.AllErrors;
            //httpApplication.Context;
            //httpApplication.Request;
            //httpApplication.Response;
            //httpApplication.Session;
            //httpApplication.User;
            //httpApplication.Server;
            //httpApplication.Application;
            //httpApplication.Modules;

            AggregateException exception =
                new AggregateException("RollbarHttpModule's context error(s)", httpApplication.Context.AllErrors);

            IRollbarPackage package =
                new ExceptionPackage(exception, "HttpApplication.Context.AllErrors", true);

            // The HttpContext decorator already takes care of the HttpRequest and HttpResponse internally:
            package =
                new HttpContextPackageDecorator(package, httpApplication.Context);

            if (httpApplication.User?.Identity != null && !string.IsNullOrWhiteSpace(httpApplication.User.Identity.Name))
            {
                package = new PersonPackageDecorator(package, httpApplication.User.Identity.Name, httpApplication.User.Identity.Name, null);
            }

            this._rollbar.Error(package);
        }