开发者

Implement Exception Handling in ASP.NET C# Project

I have an application that has many tiers. as in, i have... Presentation Layer (PL) - > contains all the html My Codes Layer (CL) -> has all my code Entity Layer (EL) -> has all the container entities Business Logic Layer (BLL) -> has the necessary business logic Data Logic Layer (DLL) -> any logic against data Data Access Layer (DAL) -> one that accesses data from the database

Now i want to provide error handling in my DLL since it is responsible for executing statement like ExecureScalar and all....

And i am confu开发者_运维知识库sed as to how to go about it...i mean do i catch the error in the DLL and throw it back to the BLL and from there throw it back to my code or what....

can any one please help me how do i implement a clean and easy error handling techinque

help you be really appreciated.

Thank you.


You can look at the MS Enterprise Block for error handling and logging. It is nice in terms of configurability. Alternatively Codelpex (codeplex.com) is the community site for MS technology open source projects. Codeplex also have some error handling libraries.


In my opinion it all depends on the kind of exception and what kind of handling you want to with it.

Some errors need to be presented to the user of course. If your application relies heavily on a database connection and your database server is unreachable you need to 'bubble' (not sure if that is the right term?) your event all the way up to your GUI and let the user know that an error occurred.

But if other errors can be handled by your application itself, you just need to 'bubble' the event up to the layer where you can handle it.

As said, there are loads of libraries which can help you handle and log errors easily and the choice for such a library is completely dependent on your project and what suits your needs.


Handle all Excpetions in DLL only, call generateEmail() for notifying admin and send only user defined error messsage from DLL-->BLL-->web-Page and redirect from here to Custom error pages

.on DLL layer generate Email along all exception info with idictionary custom defined arguments (this is what i use for my arguments)

.try catch only in DLL only .Don't re throw exception on any layer..bad programming techniques .send error message from DLL--BLL-->web page .check if is the errfield !="" response.redirect("errorUserPage.")

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜