in general, you should never throw an Exception class / object directly, but only derivatives, for example:
throw new SecurityException("user should not be allowed to access this method...");
in such a situation, what do you miss in the magazine or on the page?
if you use the global application exception handler and you log in there using Log4Net
or NLog
, you must have access to the entire exception chain from external to internal, and so on, depending on how you configure and use the framework log. The yellow IIS / ASP.NET page may be incomplete, but it should show a stack trace anyway.
if you want to throw your own exception from the catch block, you are carrying the actual exception coming from the catch this way:
throw new SecurityException("user should not be allowed...", exc);
Edit : I tried what you suggested and got LogLogNet in a text file:
System.Security.SecurityException: the more obvious exception ---> System.Security.SecurityException: the original exception in EDICheckerApp.Program.boom () in C: \ DEV_RPP \ Program.cs: line 45
--- The end of the internal trace of the exception stack is in EDICheckerApp.Program.boom () in C: \ DEV_RPP \ Program.cs: line 49
in EDICheckerApp.Program.Main (String [] args) in C: \ DEV_RPP \ Program.cs: line 27
source share