Exposing Adapter's exceptions

Posts   
 
    
omar avatar
omar
User
Posts: 569
Joined: 15-Oct-2004
# Posted on: 17-Sep-2006 09:27:53   

I am extending the DAL's adapter class in my BL assembly. Though the Adapter type exposes a rich set of overridable methods at various stages, I am missing overridable routines that are called when the adapter encounters an exception during SaveEntity, DeleteEntity, ...etc.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 18-Sep-2006 06:39:08   

Exceptions are thrown (bubbled) upward. So it can be catched by whoever is calling the adapter methods.

So maybe you need to consume an adapter object and call its save or delete methods inside a try catch block and then in the catch block you may call a method of your own class.

The following is what I have in mind.


class AdapterEX : DataAccessAdapter
{
public bool SaveEntity(.....)
{
try
{   
base.SaveEntity(......);
}
catch
{
MyExceptionHandler();
}
}
}