In this post , python has a trace library to get detailed error information (line number, file name ...).
Does C # have similar functions to find out which file / line number throws an exception?
ADDED
I came up with the following code based on the answers.
using System; // https://stackoverflow.com/questions/4474259/c-exception-handling-with-a-string-given-to-a-constructor class WeekdayException : Exception { public WeekdayException(String wday) : base("Illegal weekday: " + wday) {} } class TryCatchFinally { public static void Main() { try { throw new WeekdayException("thrown by try"); } catch(WeekdayException weekdayException) { Console.WriteLine(weekdayException.Message); Console.WriteLine(weekdayException.StackTrace); } } }
And he gives me this message:
Illegal weekday: thrown by try at TryCatchFinally.Main () [0x00000] in <filename unknown>:0
source share