Red Gate forums :: View topic - Fatal exception handler is missing "inner" exception
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product support center
SmartAssembly 6
SmartAssembly 6 forum

Fatal exception handler is missing "inner" exception

Search in SmartAssembly 6 forum
Post new topic   Reply to topic
Jump to:  
Author Message
DanielRose



Joined: 30 Oct 2009
Posts: 12
Location: Aachen, Germany

PostPosted: Tue Nov 20, 2012 4:35 pm    Post subject: Fatal exception handler is missing "inner" exception Reply with quote

I have smartassembly set to report exceptions on my application with a custom template.

Today I got an exception report as screenshot only, since the fatal exception handler was being called: The normal exception handler was called to report an exception. However, the handler threw an exception (due to a cross-thread call). This was caught and the fatal exception handler got called.

So far, so good. However, the original exception is not part of the data for the fatal exception handler! I fixed the bug in the exception handler, but I can't fix the original bug since I don't know what it is. The data is simply dropped.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 443

PostPosted: Wed Nov 21, 2012 9:29 pm    Post subject: Reply with quote

This is quite complex to provide definitive solutions.

Can you try to mitigate the problem by eliminating cross-threaded calls?
Back to top
View user's profile Send private message
DanielRose



Joined: 30 Oct 2009
Posts: 12
Location: Aachen, Germany

PostPosted: Thu Nov 22, 2012 10:07 am    Post subject: Reply with quote

I fixed the cross-thread call (and other potential problems). However, if for any reason an exception occurs during the exception handler, then the data about the original exception is still lost.

The code in SA is (from disassembly, and simplified):

Code:

public abstract class UnhandledExceptionHandler
{
    private void ReportException(Exception exception, bool canContinue, bool manuallyReported)
    {
      try
      {
        ReportExceptionEventArgs e = new ReportExceptionEventArgs(reportSender, exception);
        this.OnReportException(e);
      }
      catch (Exception ex)
      {
        this.OnFatalException(new FatalExceptionEventArgs(ex));
      }
    }
}


In the catch, the original exception is lost. I'm not sure how to best fix it. Perhaps an additional property on the FatalExceptionEventArgs?
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 443

PostPosted: Thu Nov 22, 2012 2:41 pm    Post subject: Reply with quote

Firstly, thanks for taking my suggestion seriously Smile

And I understand the exact problem a little better now- thanks to your further explanation.

I don't know if the data can be obtained (or if the FatalException status necessarily means it can't) but I will discuss this with our developers in order to get a clear answer for you.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 443

PostPosted: Fri Nov 23, 2012 2:18 pm    Post subject: Reply with quote

No news just yet.

In the meantime- do you get better behaviour if you use the default standard template?
Back to top
View user's profile Send private message
DanielRose



Joined: 30 Oct 2009
Posts: 12
Location: Aachen, Germany

PostPosted: Fri Nov 23, 2012 4:31 pm    Post subject: Reply with quote

I won't get any better behavior because the original exception is never passed to the fatal exception handler. The code would need to be modified as follows:

Code:

catch (Exception ex)
{
    this.OnFatalException(new FatalExceptionEventArgs(ex, exception));
}


with the FatalExceptionEventArgs having an additional (optional) parameter for an "inner exception", since it's not possible to create an exception wrapping both exceptions or add exception as inner exception to ex (except perhaps with nasty Reflection on internal fields).
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 443

PostPosted: Mon Nov 26, 2012 4:58 pm    Post subject: Reply with quote

To save your time- I'm not getting any response from our dev teams as to whether this is expected behaviour or not so I have simply added this as a feature request.
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 443

PostPosted: Wed Nov 28, 2012 3:23 pm    Post subject: Reply with quote

The bug reference is SA-1596.

I cannot promise a speedy remedy but please check maybe each month.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group