get last exception

Posts   
 
    
jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 04-Jun-2007 22:44:26   

C# LLBL 2.0 adapter model

I have a set of BLL services. within different service functions i have blocks of code like this

using (adapter)
{
   try
   {
        adapter.SaveCollection(...);
        adapter.Commit();
   }
   catch (ORMException ex)
   {
        adapter.Rollback();
        ExceptionPolicy.HandelException(ex, "name");
   }
}

I would like to consolidate the exception logic and place the logging with the DataAccessAdapter.OnAfterTransactionRollback().

protected override void OnAfterTransactionRollback()
{
   if (LastException != null)
   {
       //log exception
   }
   base.OnAfterTransactionRollback();
}

Is there a way to access the last exception thrown from the adapter? if I google "get last exception", I get references for Server.GetLastException() which is asp.net specific. I'm hoping for something that is GUI egnostic.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 18-Jun-2007 17:44:39   

There's no mechanism build in which takes care of this, all exceptions are bubbled upwards so the caller gets the responsibility to handle it.

Frans Bouma | Lead developer LLBLGen Pro