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 9202581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:17:26+00:00 2026-06-17T23:17:26+00:00

Everyone is familiar with the default error handler for ASP.NET. The yellow boxes that

  • 0

Everyone is familiar with the default error handler for ASP.NET. The yellow boxes that contain Source Error (5 lines of code where the error happened) and Source File (filename and line number) like so:

Source Error:

Line 48:         public ActionResult TriggerException()
Line 49:         {
Line 50:            throw new SystemException("This is a generated exception to test the global error handler.");
Line 51:         }
Line 52:         


Source File: c:\MyApp\Controllers\TestToolsController.cs    Line: 50 

I am building a custom error handler and want to get these same pieces of information, but they are not contained in the exception object. Does anyone know how I may retrieve these items.

  • 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-06-17T23:17:27+00:00Added an answer on June 17, 2026 at 11:17 pm

    The line number is not available in the Exception itself, but it is available in the StackTrace, like so:

    try
    {
        // code that throws an Exception here
    }
    catch (Exception exc)
    {
        var frame = new StackTrace(exc, true).GetFrame(0); // where the error originated
        var lineNumber = frame.GetFileLineNumber();
        // Handle line numbers etc. here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone... I'm not too familiar with PHP... but I have PHP code that
Afternoon everyone. I'm not that familiar with SQLite so I haven't messed with all
I assume everyone here is familiar with the adage that all text files should
everyone. This is a piece of code from using sqlite in android tutorial: return
Long story short, a piece of code that I'm working with at work has
I'm considering two possibilities: include NUnit with the source code of an open-source project
Everyone is saying how .NET Remoting is being replaced by WCF, but I'm wondering
Everyone is familiar with the schedule problem in Computer Science. I am not asking
I currently have a piece of code that I am working on using function
everyone, I have faced one problem: The ZUL code: <window title=Hello World!! id=winMain border=none

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.