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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:39:32+00:00 2026-06-05T08:39:32+00:00

Within the code I’m responsible for, I have a few ‘throw new Exception()’ methods

  • 0

Within the code I’m responsible for, I have a few ‘throw new Exception()’ methods flying around.

The issue is, the catch is not always in the best place or even in the same class. This means when I catch an error, I don’t know where the throw originated or even if I do, there could be hundreds/thousands of lines of code in each class.

So, within the throw message, for debugging, it may be useful to state the Class Name, Project Name, Method Name and the line number for easier navigation. The line number is tricky. I can’t hard code it because as soon as I amend the code it’s unlikely to remain on the same line.

So, my 2 questions are
1) Do we like this idea or think no, there are better approaches!
2) Any ideas how to get the line number?

  • 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-05T08:39:34+00:00Added an answer on June 5, 2026 at 8:39 am

    Have you considered looking at the StackTrace information found under System.Diagnostics? An example can be found at:

    http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using c# code within a web application, I have a try catch statement in
I have code within a try/catch block with a redirect to another page. If
I have a checkout of code within a directory on my Unix box> I
I have the following code within a razor mvc3 view that is duplicated in
I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND
I want to get an App Identifier within code in Cocoa Framework Is have
Within my code a have the following abstract superclass public abstract class AbstractClass<Type extends
I have some code within one function that I want to separate into its
I have some javascript code (within an object) : toggle: function() { var me
I have the following code within the class. basically what i need is it

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.