c# - How to return an exception thrown in one project to another? -


is there way catch , return exception thrown 1 project another?

for example, i'm keeping codes in different projects . , b. if engine part , b ui part, exception occurred in engine should caught in ui well.please help.

if want catch exceptions @ ui level can not catch them @ engine level.

for running application there no difference in assembly (every project creates assembly) exception thrown.

if have catch , re-throw exception @ engine level re-throw correctly

catch(exception ex)  {      // whatever logic     throw; } 

or wrap it

catch(exception ex)  {      // whatever logic     throw new yourengineexception("some message", ex); }    

if want log it, don't it, if not cross process boundaries.

catch, log, re-throw anti pattern in opinion. creates bazillion log entries, catching @ highest possible level should enough if don't destroy stack trace.

use wrapping if can provide extra information exception. example if have 1 method loads data, changes , saves wrap exception , add "error '{0}' when saving" or else. don't forget include originating exception inner exception.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -