Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Eric: 

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 2
this 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 3
You 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
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas