Hi, I have web application with Presentaion layer,Business Layer,Data Access Layer. I am getting data by web service which is connected with my Data Access Layer.Means it is one of type of remoting i am using. Which exception i must handle in this scenario, in my DAL and Business Layer? Please guide me.
Layer architecture is notoriously poor at following the natural flow of your app, so, well, you have some choice there. I like to put this sort of code into the business layer, although I couldn't make a compelling case for it to save my life.
Hello,
I think you should not handle any errors at Data Access Layer or Business Layer. You simply have to throw it to next layer, so at last you have an error/exception at Presentation Layer. All the error/exception should be handled at Presentation Layer, the reason behind it is..
- You may change Presentation Layer in future and it will be easy and comfortable to handle it if you know the real error/exception
- You can have a class handling each type of error at presentation layer and throw custom message to the user
Still, This is my opinion and there is no hard and fast rule for that. I am also agree with "Niko" to handle such things at Business Layer.
Following article may give more light on architecture (still it is not on error handling). - http://www.codeproject.com/KB/cs/CLR%5FSP%5FLinq%5Fn-tier.aspx
I view a Webservice as just another form of Presentation layer. It should be using the same business layer components as your Web UIs, wherever possible.
Even in fairly basic REST style services, I try to always incorporate a basic Response wrapper around the requested data - this ensures that in the event of a failure, I can still return a response with an Error flag set, and hopefully some form of descriptive message.
I always try to ensure I'm not passing exception data from lower layers (eg DAL) as this can be a security issue. That exception data should generally be logged, however.