コード例 #1
0
 /// <summary>
 ///     Creates a new instance of <see cref="ExceptionProcessor" />.
 /// </summary>
 /// <param name="configuration">Current configuration.</param>
 public ExceptionProcessor(OneTrueConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException("configuration");
     }
     _configuration = configuration;
 }
コード例 #2
0
 /// <summary>
 ///     Activate our automatic detection of unhandled exceptions.
 /// </summary>
 /// <param name="configurator">config class</param>
 /// <remarks>
 ///     <para>Adds context collectecors for forms, query string, sessions, user agent and http headers.</para>
 ///     <para>
 ///         MVC exceptions are dected through a custom global error filter.
 ///     </para>
 /// </remarks>
 public static void CatchMvcExceptions(this OneTrueConfiguration configurator)
 {
     configurator.ContextProviders.Add(new FormProvider());
     configurator.ContextProviders.Add(new QueryStringProvider());
     configurator.ContextProviders.Add(new SessionProvider());
     configurator.ContextProviders.Add(new HttpHeadersProvider());
     GlobalFilters.Filters.Add(new OneTrueErrorFilter());
     ErrorHttpModule.Activate();
 }
コード例 #3
0
 public static void CatchWinFormsExeptions(this OneTrueConfiguration configurator)
 {
     if (configurator == null)
     {
         throw new ArgumentNullException("configurator");
     }
     WinFormsErrorReporter.Activate();
     OneTrue.Configuration.ContextProviders.Add(new OpenFormsCollector());
 }
コード例 #4
0
 /// <summary>
 ///     Take a screen shot of every form that is opened when an error happen.
 /// </summary>
 /// <param name="configurator">OneTrueError configurator (accessed through <see cref="OneTrue.Configuration" />).</param>
 public static void TakeScreenshots(this OneTrueConfiguration configurator)
 {
     if (configurator == null)
     {
         throw new ArgumentNullException("configurator");
     }
     WinFormsErrorReporter.Activate();
     OneTrue.Configuration.ContextProviders.Add(new ScreenshotProvider(true));
 }
コード例 #5
0
        /// <summary>
        ///     Activate the ASP.NET error catching library
        /// </summary>
        /// <param name="configurator">instance.</param>
        public static void CatchAspNetExceptions(this OneTrueConfiguration configurator)
        {
            // the HTTP module is always loaded.
            // this setting will be read by it to check if
            // errors should be caught.
            CatchExceptions = true;

            configurator.ContextProviders.Add(new FormProvider());
            configurator.ContextProviders.Add(new QueryStringProvider());
            configurator.ContextProviders.Add(new SessionProvider());
            configurator.ContextProviders.Add(new HttpHeadersProvider());
        }
コード例 #6
0
        /// <summary>
        ///     Set a customized form which will be shown when OneTrueError detects an uncaught exception.
        /// </summary>
        /// <param name="configurator">OneTrueError configurator (accessed through <see cref="OneTrue.Configuration" />)</param>
        /// <param name="formFactory">Factory used to create the form.</param>
        /// <example>
        ///     <para>Start by creating your custom form. It should contain something like this:</para>
        ///     <code>
        /// public partial class CustomReportDialog : Form
        /// {
        ///     public CustomReportDialog()
        ///     {
        ///         InitializeComponent();
        ///     }
        ///
        ///     // It's important that you store it
        ///     public string reportId { get; set; }
        ///
        ///     // And do something like this when the user clicks on the
        ///     // send report button
        ///     private void btnSubmit(object sender, EventArgs e)
        ///     {
        ///         var info = tbErrorDetails.Text;
        ///         var email = tbEmail.Text;
        ///
        ///         // supplied info, attach it.
        ///         if (!string.IsNullOrEmpty(info) || !string.IsNullOrEmpty(email))
        ///         {
        ///             OneTrue.SendReport(reportId, new UserSuppliedInformation(info, email));
        ///         }
        ///         else
        ///         {
        ///             // otherwise just send error and all contexts.
        ///             OneTrue.SendReport(reportId);
        ///         }
        ///     }
        ///
        ///     private void btnCancel_Click(object sender, EventArgs e)
        ///     {
        ///         Close();
        ///     }
        /// }
        /// </code>
        ///     <para>
        ///         Then configure OTE to use it:
        ///     </para>
        ///     <code>
        /// // don't forget to set the error reporter first.
        ///
        /// OneTrue.Configuration.CatchWinFormsExceptions();
        /// OneTrue.Configuration.SetErrorForm(context => new CustomReportDialog() { reportId = context.reportId });
        /// </code>
        /// </example>
        public static void SetErrorForm(this OneTrueConfiguration configurator,
                                        Func <FormFactoryContext, Form> formFactory)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException("configurator");
            }
            if (formFactory == null)
            {
                throw new ArgumentNullException("formFactory");
            }

            WinFormsErrorReporter.FormFactory = formFactory;
        }
コード例 #7
0
 /// <summary>
 ///     Sets the error page.
 /// </summary>
 /// <param name="configurator">The configurator.</param>
 /// <param name="errorPageGenerator">service used to provide error pages</param>
 /// <exception cref="System.ArgumentNullException">virtualPathOrCompleteErrorPageHtml</exception>
 /// <exception cref="System.Configuration.ConfigurationErrorsException">
 ///     You have to have a <![CDATA[<form>]]> tag pointing at 'http://yourwebsite/onetrueerror/' in your error page if you
 ///     would like to collect error information.\r\n(Or set OneTrue.Configuration.AskUserForPermission and
 ///     OneTrue.Configuration.AskUserForDetails to false)
 ///     or
 ///     You have to have one or more '$reportId$' tags in your HTML which can be replaced with the correct report id
 ///     upon errors.
 /// </exception>
 /// <remarks>
 /// <para>
 /// For this plugin to work, you need to make sure that the <code>App_Data</code> folder exists and that the application pool account (typically IUSR) have write access to it. The folder
 /// is used to store error reports until they have been successfully uploaded to OneTrueError. In that way we can make sure that no reports are lost (even if there are network failure or other issues).
 /// </para>
 /// <para>
 ///     You can either return a complete error page (no virtual URIs for images etc) or a virtual path to a page which will
 ///     create the error page.
 /// </para>
 ///     <para>If you do the latter you can </para>
 ///     <para>
 ///         It's important that you've configured <c>OneTrue.Configuration.AskUserForDetails</c> and
 ///         <c>OneTrue.Configuration.AskUserForPermission</c> correctly if you
 ///         are using a custom error page, as setting one of those to true will result in that this module expects a HTTP
 ///         POST before sending the report.
 ///     </para>
 ///     <para>
 ///         All tags</para>
 ///         <list type="table">
 ///             <item>
 ///                 <term>$URL$</term>
 ///                 <description>
 ///                     Full URL which will be picked up by the OneTrueError module (to be able to send the report
 ///                     to the OneTrueError service)
 ///                 </description>
 ///             </item>
 ///             <item>
 ///                 <term>$reportId$</term>
 ///                 <description>Token generated which is a unique identifier for the current exception.</description>
 ///             </item>
 ///         </list>
 ///     <para>Example HTML error page:</para>
 /// <code>
 /// <![CDATA[<!DOCTYPE html>
 /// <html lang="en">
 /// <head>
 ///     <meta charset="utf-8" />
 ///     <title>Something failed</title>
 ///     <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
 ///     <style type="text/css">
 ///         /*CssStyles*/
 ///         body {
 ///             background: #f0f0f0;
 ///             font-family: Segoe UI, Arial;
 ///         }
 ///
 ///         form {
 ///             padding: 10px;
 ///             background: white;
 ///             border: 1px solid #eeeeee;
 ///             width: 500px;
 ///         }
 ///     </style>
 /// </head>
 /// <body>
 ///     <h1>Something went wrong</h1>
 ///     <form method="post" action="$URL$">
 ///         <p>
 ///             We are terribly sorry for that.
 ///         </p>
 ///         <p>
 ///             You can press the "Back" browser button to try again, or press the "Continue" button below.
 ///         </p>
 ///         <input type="hidden" value="$reportId$" name="reportId" />
 ///         <div class="AllowSubmissionStyle">
 ///             <p>
 ///                 However, If you allow us to collect error information we'll be able to analyze this error and fix it as soon as possible.
 ///             </p>
 ///             <input type="checkbox" name="Allowed" value="true" />
 ///             I allow you to collect information.
 ///         </div>
 ///         <div class="AllowFeedbackStyle">
 ///             <p>You can also help us understand this new feature by type in some information about how you got here:</p>
 ///             <textarea rows="10" cols="40" name="Description"></textarea>
 ///         </div>
 ///
 ///         <div class="AskForEmailAddress">
 ///             <p>You can enter your email if you would like to get notified when this error has been fixed:</p>
 ///             <input type="text" name="email" placeholder="email address" />
 ///         </div>
 ///         <hr/>
 ///         <input type="submit" value="Continue" />
 ///     </form>
 /// </body>
 /// </html>
 /// ]]>
 /// </code>
 /// </remarks>
 public static void SetErrorPageGenerator(this OneTrueConfiguration configurator, IErrorPageGenerator errorPageGenerator)
 {
     ErrorPageGenerator = errorPageGenerator;
 }
コード例 #8
0
 /// <summary>
 ///     Creates a new instance of <see cref="UploadDispatcher" />.
 /// </summary>
 /// <param name="configuration">Used to check at runtime of queuing is enabled or not.</param>
 public UploadDispatcher(OneTrueConfiguration configuration)
 {
     _configuration = configuration;
     _reportQueue   = new UploadQueue <ErrorReportDTO>(UploadReportNow);
     _feedbackQueue = new UploadQueue <FeedbackDTO>(UploadFeedbackNow);
 }
コード例 #9
0
 /// <summary>
 ///     Display the built in error pages.
 /// </summary>
 /// <remarks>
 ///     <para>
 ///         OneTrueError has a set of built in error pages which can shown when an exception is thrown.
 ///     </para>
 /// </remarks>
 public static void DisplayErrorPages(this OneTrueConfiguration instance)
 {
     ErrorHttpModule.DisplayErrorPage = true;
 }