N We have a function of the log utility that we call quite often, and I wanted to revive it by adding a call to Server.GetLastError() , and if there is an error for logging in. The log function is part of a separate project, so I tried using HttpContext.Current.Server.GetLastError() (as well as for the Request, ServerVariables and Session properties). During testing, I created a simple exception:
int i=0, j=0; try { int k = i / j; } catch (Exception E) { Tools.CooLog("in"); } Tools.CooLog("out");
To find out if "HttpContext.Current.Server.GetLastError ()" will throw an exception when calling Tools.CooLog("out"); .
Instead, I had two big surprises 1. Both calls to HttpContext.Current.Server.GetLastError() returned null. 2. And, perhaps, the strangest thing is that during the first call to CooLog in the locals section I saw a little of my young, beautiful and PHP version - I saw that there is a value called $ exception, and, surprisingly, the exception is HttpContext.Current.Server.GetLastError() failed to get!

So my questions are 1. Why does HttpContext.Current.Server.GetLastError () return null? ( HttpContext.Current.Request.ServerVariables works fine) 2. Where does this $ exception come from? is there any way to use it? (in the second call to CooLog, the variable is undefined)
SimSimY
source share