Example #1
0
        public void DontStripIfNoInnerException()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException();

              RaygunMessage message = _client.CreateMessage(wrapper);
              Assert.AreEqual("System.Web.HttpUnhandledException", message.Details.Error.ClassName);
              Assert.IsNull(message.Details.Error.InnerError);
        }
        public void DontStripIfNoInnerException()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException();

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper).ToList();
              Assert.AreEqual(1, exceptions.Count);
              Assert.Contains(wrapper, exceptions);
        }
        public void TestWriteXmlException() {
            var ex = new HttpUnhandledException("This is a test");

            var buffer = new StringBuilder();
            using (XmlWriter writer = XmlWriter.Create(buffer))
                ObjectDumper.WriteXml(ex, 1, new[] { "Message" }, writer);

            Assert.AreEqual(296, buffer.ToString().Length);

        }
        public void http_unhandled_exception_alone_should_log()
        {
            var client = new FakeAirbrakeClient();
            var exception = new HttpUnhandledException("unhandled");

            exception.SendToAirbrake(client: client);

            Assert.AreEqual(1, client.SentExceptions.Count);
            Assert.AreEqual(1, client.SentNotices.Count);
            Assert.AreEqual("unhandled", client.SentExceptions[0].Message);

        }
        public override void Log(ExceptionLoggerContext context)
        {
            var httpContext = GetHttpContext(context.Request);

            if (httpContext == null)
            {
                return;
            }

            Exception exceptionToRaise = new HttpUnhandledException(null, context.Exception);

            var signal = ErrorSignal.FromContext(httpContext);
            signal.Raise(exceptionToRaise, httpContext);
        }
Example #6
0
        Exception BuildParseError(Exception e, string capsKey)
        {
            string message = SR.GetString(SR.Invalid_string_from_browser_caps, e.Message, capsKey, this[capsKey]);

            // to show ConfigurationException in stack trace
            ConfigurationException configEx = new ConfigurationException(message, e);

            // I want it to look like an unhandled exception
            HttpUnhandledException httpUnhandledEx = new HttpUnhandledException(null, null);

            // but show message from outer exception (it normally shows the inner-most)
            httpUnhandledEx.SetFormatter(new UseLastUnhandledErrorFormatter(configEx));

            return(httpUnhandledEx);
        }
        public override void Log(ExceptionLoggerContext context)
        {
            HttpContext httpContext = GetHttpContext(context.Request);

            if (httpContext == null)
            {
                return;
            }

            // Wrap the exception in an HttpUnhandledException so that ELMAH can capture the original error page.
            Exception exceptionToRaise = new HttpUnhandledException(message: null, innerException: context.Exception);

            // Send the exception to ELMAH (for logging, mailing, filtering, etc.).
            Elmah.ErrorSignal signal = Elmah.ErrorSignal.FromContext(httpContext);
            signal.Raise(exceptionToRaise, httpContext);
        }
        public override void Log(ExceptionLoggerContext context)
        {
            // Retrieve the current HttpContext instance for this request.
            var httpContext = GetHttpContext(context.Request);

            if (httpContext == null)
            {
                return;
            }

            // Wrap the exception in an HttpUnhandledException so that ELMAH can capture the original error page.
            var exceptionToRaise = new HttpUnhandledException(message: null, innerException: context.Exception);

            // Send the exception to ELMAH (for logging, mailing, filtering, etc.).
            var signal = ErrorSignal.FromContext(httpContext);
            signal.Raise(exceptionToRaise, httpContext);
        }
Example #9
0
        public void StripMultipleWrapperExceptions()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException("Something went wrong", _exception);
              TargetInvocationException wrapper2 = new TargetInvocationException(wrapper);

              RaygunMessage message = _client.CreateMessage(wrapper2);
              Assert.AreEqual("System.NullReferenceException", message.Details.Error.ClassName);
        }
Example #10
0
        public void StripHttpUnhandledExceptionByDefault()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException("Something went wrong", _exception);

              RaygunMessage message = _client.CreateMessage(wrapper);
              Assert.AreEqual("System.NullReferenceException", message.Details.Error.ClassName);
        }
        protected void Application_Error(object sender, EventArgs e)
        {
            Application["LastError"] = Server.GetLastError();

#if DEBUG
            var lastError = Server.GetLastError();
            string sql = null;

            try
            {
                sql = lastError.Data["SQL"] as string;
            }
            catch
            {
                // skip it
            }

            if (sql == null) return;

            var ex = new HttpUnhandledException("An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.", lastError);

            Server.ClearError();

            var html = ex.GetHtmlErrorMessage();
            var traceNode = "<b>Stack Trace:</b>";
            html = html.Replace(traceNode, @"<b>Sql:</b><br><br>
    <table width='100%' bgcolor='#ffffccc'>
    <tbody><tr><td><code><pre>" + sql + @"</pre></code></td></tr></tbody>
    </table><br>" + traceNode);

            HttpContext.Current.Response.Write(html);
            HttpContext.Current.Response.StatusCode = 500;
            HttpContext.Current.Response.Status = "Internal Server Error";
            HttpContext.Current.Response.End();
#endif
        
        }
Example #12
0
 // GET: Error
 public ActionResult Index()
 {
     Exception ex = new HttpUnhandledException();
     return View("Error", ex);
 }
Example #13
0
        public void StripHttpUnhandledExceptionByDefault()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException("Something went wrong", _exception);

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper).ToList();
              Assert.AreEqual(1, exceptions.Count);
              Assert.Contains(_exception, exceptions);
        }
Example #14
0
        public void StripMultipleWrapperExceptions()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException("Something went wrong", _exception);
              TargetInvocationException wrapper2 = new TargetInvocationException(wrapper);

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper2).ToList();
              Assert.AreEqual(1, exceptions.Count);
              Assert.Contains(_exception, exceptions);
        }