0

I have a service layer which references the dao layer. I use ninject's inversion control to tie the implementation.

public class DaoA : IDaoA
{   
    private DaoA _dao;
    public void daoMethod() {
       //throw DBUpdate exception   
    }    
}


public class ServiceA : BaseService 
{   
    private DaoA _dao;
    public result methodA() {
       _dao.daoMethod();    
    }
}

Now I would like to avoid the try catch block in the daoMethod. Is there a way I could catch this exception at some BaseService like we do to catch OnException method in the Attribute classes in .NET?

mipe34
  • 5,596
  • 3
  • 26
  • 38
ssinganamalla
  • 1,250
  • 3
  • 12
  • 19
  • I think this is what I need. Spring.NET AOP http://stackoverflow.com/questions/8167718/spring-net-aop-exceptionhandleradvice-doesnt-replace-custom-exception – ssinganamalla Jan 16 '13 at 22:43

1 Answers1

0

Yes, if you do not catch the exception in the DAO layer you can catch it in the services layer.

Z .
  • 12,657
  • 1
  • 31
  • 56
  • Is it possible to catch it in a separate class so that it avoids the boiler plate code of try catch block in every service method? Is it a good practice? – ssinganamalla Jan 16 '13 at 19:20
  • 1
    http://www.codeproject.com/Articles/337564/Aspect-Oriented-Programming-Using-Csharp-and-PostS has a way of doing it. – ssinganamalla Jan 16 '13 at 19:32