Where should I handle the exceptions, in the BLL, DAL or PL ?

Posted by Puneet Dudeja on Stack Overflow See other posts from Stack Overflow or by Puneet Dudeja
Published on 2010-06-14T17:03:19Z Indexed on 2010/06/14 18:52 UTC
Read the original article Hit count: 153

Filed under:
|
|
|

Which is the best place to handle the exceptions ? BLL, DAL or PL ?

Should I allow the methods in the DAL and BLL to throw the exceptions up the chain and let the PL handle them? or should I handle them at the BLL ?

e.g

If I have a method in my DAL that issues "ExecuteNonQuery" and updates some records, and due to one or more reason, 0 rows are affected. Now, how should I let my PL know that whether an exception happened or there really was no rows matched to the condition. Should I use "try catch" in my PL code and let it know through an exception, or should I handle the exception at DAL and return some special code like (-1) to let the PL differentiate between the (exception) and (no rows matched condition i.e. zero rows affected) ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET