Example #1
0
 /// <summary>
 /// Raises the error complete event.
 /// </summary>
 /// <param name="e">The <see cref="Bugx.Web.BugEventArgs"/> instance containing the event data.</param>
 static void OnErrorComplete(BugEventArgs e)
 {
     if (ErrorComplete != null)
     {
         SafeRunner.Invoke(delegate { ErrorComplete(HttpContext.Current.ApplicationInstance, e); });
     }
 }
Example #2
0
File: Bot.cs Project: mbsky/bugx
 /// <summary>
 /// Handles the ErrorComplete event of the ErrorModule control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Bugx.Web.BugEventArgs"/> instance containing the event data.</param>
 void ErrorModule_ErrorComplete(object sender, BugEventArgs e)
 {
     HttpContext context = HttpContext.Current;
     Exception exception = context.Error.GetBaseException();
     Message(string.Format(CultureInfo.InvariantCulture,
                           Texts.WarningErrorInProduction,
                           context.Request.Url,
                           exception.Message,
                           exception.GetType().FullName,
                           ExceptionHelper.GetRelevantSource(context.Error) ?? exception.Source,
                           e.BugReport,
                           e.Bug.ErrorFromBot));
 }
Example #3
0
 /// <summary>
 /// Raises the error complete event.
 /// </summary>
 /// <param name="e">The <see cref="Bugx.Web.BugEventArgs"/> instance containing the event data.</param>
 static void OnErrorComplete(BugEventArgs e)
 {
     if (ErrorComplete != null)
     {
         SafeRunner.Invoke(delegate {ErrorComplete(HttpContext.Current.ApplicationInstance, e);});
     }
 }
Example #4
0
        /// <summary>
        /// Handles the Error event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        static void Application_Error(object sender)
        {
            if (IsReBug)
            {//Error handling is disabled.
                return;
            }
            HttpContext context = ((HttpApplication) sender).Context;
            if (context == null || context.Error == null)
            {
                return;
            }
            BugDocument bug = new BugDocument();
            XmlNode root = bug.AppendChild(bug.CreateElement("bugx"));
            bug.CreationDate = DateTime.Now;
            bug.ErrorFromBot = BrowserHelper.IsKnownBot(context.Request.UserAgent);
            BugEventArgs bugEventArgs = new BugEventArgs();
            bugEventArgs.Bug = bug;
            DataToSave dataToSave = BugxConfiguration.DataToSave;
            string errorId = BuildUniqueIdentifier(context.Error);
            string bugVirtualPath = "~/bugx/errors/" + context.Error.GetBaseException().GetType().FullName.Replace('.', '/') + "/" + errorId;
            DirectoryInfo destination = new DirectoryInfo(context.Request.MapPath(bugVirtualPath));
            if (!destination.Exists)
            {
                destination.Create();
            }
            string fileName = DateTime.Now.ToUniversalTime().ToString("/yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture) + ".bugx";
            if (File.Exists(fileName))
            {
                return;
            }
            //Minimum data to save.
            SaveUrl(root, context);
            SaveRequest(root, context);

            if ((dataToSave & DataToSave.Session) != 0)
            {
                SaveSession(root, context);
            }
            if ((dataToSave & DataToSave.Cache) != 0)
            {
                SaveCache(root, context);
            }
            if ((dataToSave & DataToSave.Context) != 0)
            {
                SaveContext(root, context);
            }
            if ((dataToSave & DataToSave.Application) != 0)
            {
                SaveApplication(root, context);
            }
            if ((dataToSave & DataToSave.User) != 0)
            {
                SaveUser(root, context);
            }
            if ((dataToSave & DataToSave.Exception) != 0)
            {
                SaveException(root, context);
            }
            OnError(bugEventArgs);
            try
            {
                bug.Save(destination.FullName + fileName);
                bugEventArgs.BugUri = ExceptionHelper.BuildBugUri(bugVirtualPath + "/" + fileName);
                bugEventArgs.BugReport = ExceptionHelper.BuildBugReportUri(bugVirtualPath + "/" + fileName);
                if (MaySendErrorComplete(errorId) && !BugxConfiguration.ShouldBeFiltered(errorId))
                {
                    OnErrorComplete(bugEventArgs);
                }
            }catch(IOException){}//Nothing to do if the same bug arrives twice.
        }
Example #5
0
        /// <summary>
        /// Handles the Error event of the Application control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        static void Application_Error(object sender)
        {
            if (IsReBug)
            {//Error handling is disabled.
                return;
            }
            HttpContext context = ((HttpApplication)sender).Context;

            if (context == null || context.Error == null)
            {
                return;
            }
            BugDocument bug  = new BugDocument();
            XmlNode     root = bug.AppendChild(bug.CreateElement("bugx"));

            bug.CreationDate = DateTime.Now;
            bug.ErrorFromBot = BrowserHelper.IsKnownBot(context.Request.UserAgent);
            BugEventArgs bugEventArgs = new BugEventArgs();

            bugEventArgs.Bug = bug;
            DataToSave    dataToSave     = BugxConfiguration.DataToSave;
            string        errorId        = BuildUniqueIdentifier(context.Error);
            string        bugVirtualPath = "~/bugx/errors/" + context.Error.GetBaseException().GetType().FullName.Replace('.', '/') + "/" + errorId;
            DirectoryInfo destination    = new DirectoryInfo(context.Request.MapPath(bugVirtualPath));

            if (!destination.Exists)
            {
                destination.Create();
            }
            string fileName = DateTime.Now.ToUniversalTime().ToString("/yyyyMMddTHHmmssZ", CultureInfo.InvariantCulture) + ".bugx";

            if (File.Exists(fileName))
            {
                return;
            }
            //Minimum data to save.
            SaveUrl(root, context);
            SaveRequest(root, context);

            if ((dataToSave & DataToSave.Session) != 0)
            {
                SaveSession(root, context);
            }
            if ((dataToSave & DataToSave.Cache) != 0)
            {
                SaveCache(root, context);
            }
            if ((dataToSave & DataToSave.Context) != 0)
            {
                SaveContext(root, context);
            }
            if ((dataToSave & DataToSave.Application) != 0)
            {
                SaveApplication(root, context);
            }
            if ((dataToSave & DataToSave.User) != 0)
            {
                SaveUser(root, context);
            }
            if ((dataToSave & DataToSave.Exception) != 0)
            {
                SaveException(root, context);
            }
            OnError(bugEventArgs);
            try
            {
                bug.Save(destination.FullName + fileName);
                bugEventArgs.BugUri    = ExceptionHelper.BuildBugUri(bugVirtualPath + "/" + fileName);
                bugEventArgs.BugReport = ExceptionHelper.BuildBugReportUri(bugVirtualPath + "/" + fileName);
                if (MaySendErrorComplete(errorId) && !BugxConfiguration.ShouldBeFiltered(errorId))
                {
                    OnErrorComplete(bugEventArgs);
                }
            }catch (IOException) {}//Nothing to do if the same bug arrives twice.
        }