views:

413

answers:

2

hi,

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 confused 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.

A: 

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.

Kangkan
A: 

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.

Wim Haanstra
Out of curiosity: what do you mean by *libraries which can help you handle and log errors easily*? I know log4net for example; is this what you mean (that would then be more on the "log" side, I assume)? What kind of library would/could help me with *handling errors*? I am asking because I am thinking about something similar as the OPs question.
scherand
Error handling is the job of the programmer. The library or framework (in the line of log4net) can help you capture and handle the exceptions that are yet to be handled. A good piece of code is supposed to handle known exceptions and generate the unknown exceptions.
Kangkan