Options

Error Reporting - Send Error Report in Background Via Code

memeDevelopermemeDeveloper Posts: 21
edited July 3, 2012 7:19AM in SmartAssembly
Hi

I am using Smart Assembly 6 - Developer Edition. Mainly I am using the Error Reporting Feature and I have created a custom template for the error dialog box that gets shown to the user by modifying the "Custom UI" template in the SDK. Now, I need to show this dialog box to users for some exceptions while not show it for other exceptions.

I know that the OnReporException method in the "UnhandledExceptionHandlerWithAdvancedUI" class is what handles showing the dialog box.

I have checked the "UnhandledExceptionHandlerWithoutUI" class which is used to report errors without a dialog box (in the background) and the OnReportException code is different:

protected override void OnReportException(ReportExceptionEventArgs e)
{
for (int i=0; i<3; i++)
{
if (e.SendReport()) break;
}
e.TryToContinue = true;
}


If I use this code is my custom template instead of the one that shows the form, the reports gets sent in the background without a dialog box.

However, I need to have the option
to send the report in the background for some exceptions only and the rest by showing the custom dialog box.

Can that be achieved with Smart Assembly Error Reporting SDK? Is there a method that I can call to send that error report in the background ?


Thanks

Comments

  • Options
    Yes- this works in a straight-forward way. For example:


    //////////////////
    protected override void OnReportException(ReportExceptionEventArgs e)
    {



    if (MyStaticBoolean)
    {

    e.SendReport();

    e.TryToContinue = true;


    }


    else
    {

    ExceptionReportingForm form = new ExceptionReportingForm(this, e);
    form.ShowDialog();

    }



    }

    ////

    i.e. just put the conditional logic in the OnReportException Method. Bingo!
  • Options
    Thanks for the reply, I have tried your suggestion and it works. I will have to set that boolean variable everywhere in my application where I don't want to show the dialog box but still I am glad I am able to do that now. Thanks.
  • Options
    One more question, Will this work with Handled Exception, I know that I can add ExceptionReporting.Report(ex); in the catch block and it will show the error dialog box but how can I call OnReportException from the catch block in order to report it silently in the background without the dialog box ?
  • Options
    If you rethrow the handled exception- it should behave exactly the same as an unhandled exception.
Sign In or Register to comment.