c# - where and how many try & catch blocks should I write? -
c# - where and how many try & catch blocks should I write? -
i wonder @ levels of application whoudl write try-catch?
dal? cache? bl? ui-logic?
if write log , re-throw it
should utilize try-catch in every function?
aswuming function can have exception didn't think of
well, depends. in ui layer, grab errors globally in application_error, , handle these accordingly. try-catch errors not want bubble ui , cause redirection generic error page. has been effective me in reporting most, if not all, errors.
some people handle errors differently; they'll grab errors in business layer, , either log , homecoming them bll, or log , rethrow generic error. instance, check out how enterprise library exception block approaches errors.
you can utilize aop library postsharp attach objects want handle errors for, or utilize mvc's exception filtering handling errors too.
c# asp.net asp.net-mvc
Comments
Post a Comment