When to use try/catch

Posted by coffeeaddict on Stack Overflow See other posts from Stack Overflow or by coffeeaddict
Published on 2010-03-24T22:14:18Z Indexed on 2010/03/24 22:23 UTC
Read the original article Hit count: 197

Filed under:
|

I'm always finding myself wanting to put a try/catch around the lets say Business Layer methods. But I feel though that I don't need a try/catch if I'm simply rethrowing it up to the Presentation Layer. Is that right? I should not be rethrowing an exception from code that's wrapped in a try/catch in a BL method and should be letting the caller which would be from the Presentation Layer code be using a try/catch to handle it there?

The BL method will throw an error without the try/catch anyway..the compiler will. So it wouldn't make sense to use a try/catch in a BL method that's to be consumed by a layer higher up correct?

© Stack Overflow or respective owner

Related posts about c#

Related posts about exception-handling