Views: 10.6K
Replies: 3
Archived
|
Exception Handling in multi-tier applicationsHello,
In a 3-tier system where should we put the error handler ? One in each layer? Or just on the service layer (where it handles error of validation BL and DAL) and the presentation layer (as information to the user side) ? Best Regards, Eric Santoso Eric Santoso, Nov 14, 2015
|
|
Reply 1Eric:
If the purpose of catching exceptions is to collect execution context information and then re-throw a new Exception, then that should be fine. Generally, well designed web applications have very few places that actually handle exceptions. Jack Jack Poorte, Nov 17, 2015
|
|
Reply 2this time I have done is, to create a custom exception to DAL and SL ...
if something goes wrong in the DAL, I will write a log and then re-throw with new custom exception (for DAL) in the Service Layer I catch a custom exception (for DAL) and I re-throw again with a custom exception (for SL) so also happens if the validation process on BL, if the validation does not fit then I will e-throw again with a custom exception (for SL) at the presentation layer in Model I catch a custom exception (for SL) and I re-throw Application Exception in the form (windows form) that I catch the exception (global exception) with this way, did I make a mistake? or I get into bad practice Best Regards, Eric Santoso Eric Santoso, Nov 17, 2015
|
|
Reply 3You should only catch exceptions when you can actually correct the situation.
If not, there is no point in catching them (other than logging perhaps and then re-throwing them). In our own work we mostly rely on the catchall error handler in global asax (you see an example in our .NET Pattern Framework code). That is where we log the exception (to the database) and let the application display the standard error page. Hope this helps Jack Jack Poorte, Nov 16, 2015
|