Пример #1
0
        protected void Application_Error()
        {
            var             exception         = Server.GetLastError();
            var             httpContext       = HttpContext.Current;
            IRollbarPackage packagingStrategy = new ExceptionPackage(exception, "EXCEPTION intercepted by MvcApplication.Application_Error()");

            if (httpContext != null)
            {
                packagingStrategy = new HttpContextPackageDecorator(packagingStrategy, httpContext);
            }
            RollbarLocator.RollbarInstance.Critical(packagingStrategy);
        }
Пример #2
0
        private void Page_Error(object sender, EventArgs e)
        {
            // Get last error from the server.
            Exception exception = Server.GetLastError();

            // Let's report to Rollbar on the Page Level:
            var metaData = new Dictionary <string, object>();

            metaData.Add("reportLevel", "PageLevel");
            metaData.Add("failedPage", this.AppRelativeVirtualPath);
            IRollbarPackage package = new ExceptionPackage(exception, "Page_Error", true);

            package = new CustomKeyValuePackageDecorator(package, metaData);
            package = new HttpContextPackageDecorator(package, this.Context);
            RollbarLocator.RollbarInstance.Error(package);

            // Handle specific exception.
            if (exception is InvalidOperationException)
            {
                // Pass the error on to the error page.
                Server.Transfer("ErrorPage.aspx?handler=Page_Error%20-%20Default.aspx", true);
            }
        }