Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:56:57+00:00 2026-05-25T05:56:57+00:00

H We have log utility function that we call pretty often and I wanted

  • 0

H
We have log utility function that we call pretty often and I wanted to spice it up by adding a call to Server.GetLastError() and if there is an error to log as well.
The log function is part of separate project so I tried to use HttpContext.Current.Server.GetLastError() (As I do for the Request, ServerVariables and Session properties).
During the testing I created simple exception:

 int i=0, j=0;
try
{
    int k = i / j;
}
catch (Exception E)
{
    Tools.CooLog("in");
}
Tools.CooLog("out");

In order to find out if “HttpContext.Current.Server.GetLastError()” will return the exception when Tools.CooLog("out"); is called.

Instead I had two big surprises
1. In both of the calls HttpContext.Current.Server.GetLastError() returned null.
2. And maybe the weirdest is that during the first call of CooLog in the locals section I saw a bit of my young, handsome and PHP version – I saw that there is value called $exception and surprisingly it ha the exception that HttpContext.Current.Server.GetLastError() failed to retrieve!

$exception is defined and HttpContext.Current.Server.GetLastError() fails

So my questions are
1. Why the HttpContext.Current.Server.GetLastError() returns null ? (HttpContext.Current.Request.ServerVariables works fine)
2. Where that $exception comes from? is there a way to use it? (in the second call to CooLog the variable is undefined)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:56:58+00:00Added an answer on May 25, 2026 at 5:56 am

    That is a special debugger variable. You cannot access it via code.

    The reason you don’t see it in the Watch window, is that the exception has either been:

    • Handled

    or

    • The Application.Error event has not been fired yet.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a system call in Perl that looks like this: system('/path/to/utility >> /redirect/to/log
I have a log function on my admin panel that checks user input for
I have a multi-threading Python program, and a utility function, writeLog(message) , that writes
I have a thread that get I initialize like this: Utility.Log(1); myThread = new
We've faced strange problem. We have log on service, that authenticates user, adds auth
I have a log that is really huge. (millions of rows) LogTable ------- ID
I have a log file in SqlServer that stores the time an application started,
I have several question: If there is an error which has to be displayed
I have a $.post function inside of a loop. All it does it call
I have dmp file that was created by EXP utility. The source database has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.