Exceptions not being raised

Exceptions not being raised

Old forum URL: forums.lhotka.net/forums/t/4311.aspx


ajj3085 posted on Thursday, February 07, 2008

Hi,

I recently overrode DataPortal_OnDataPortalException in my Csla derived base classes.  The idea was that if an error happens on the dataportal and remoting was being used, the exception details could be emailed to me.  Failing that, an attempt is made to write to the Event log.

Since I've added this, exceptions on the data portal no longer seem to be raised back to the client.  In fact, the transaction completes successfully even though not all of the data was written.  (using transaction scope).

Now, I believe that my attempt to write to the event log is causing an exception which I'm not catching.. but I'm disturbed by the fact that it seems the exception is being lost somewhere.

Has anyone else come across this?

Thanks
Andy

david.wendelken replied on Thursday, February 07, 2008

Maybe your new code has a boo-boo in it.  Care to post it so we can take a look too?

ajj3085 replied on Friday, February 08, 2008

Sorry, I was out most of yesterday.

Here's the override code.

Find attached the ExceptionEmailer class.

Thanks
Andy

        /// <summary>In a remoting scenario, the error email from the client
        /// isn't useful anymore, so send the email here, but still allow it
        /// to bubble up to the client.</summary>
        /// <param name="e">Data portal event arguments.</param>
        /// <param name="ex">The exception which occured.</param>
        protected override void DataPortal_OnDataPortalException(
            DataPortalEventArgs e,
            Exception ex
        ) {
            if ( ApplicationContext.ExecutionLocation ==
                ApplicationContext.ExecutionLocations.Server ) {

                ExceptionEmailer.SendErrorEmail( ex );
            }

            base.DataPortal_OnDataPortalException( e, ex );
        }

ajj3085 replied on Friday, February 08, 2008

After posting this code, I reviewed it and realized it would not be thread safe, which is bad because I'm using remoting and IIS.. so that static Exception variable could be changed by many threads.

I now use ParameterizedThreadStart and removed and static fields from that class.  Maybe this was causing an issue?  I don't know.. I still need to test to ensure exceptions are not getting lost.

Andy

Copyright (c) Marimer LLC