[RESOLVED] [2005] Logging error locations
Hi,
Is there a way to have VB return the name of the current sub/function? What I'd like to do is something like this:
public sub MyTest()
try
dim test as integer = 0
test = "oops, it's a string"
catch ex as exception
console.writeline ex.message & " occurred in " & <?????>
end try
end sub
So the output would be:
Conversion from string "test" to type 'Integer' is not valid occurred in MyTest
Re: [2005] Logging error locations
Just do this:
vb Code:
Console.WriteLine(ex.ToString())
and you'll get the error message and the whole stack trace. If you want to pick and choose what info you want then you can use the exception's StackTrace property to get individual stack frames. The top frame will be the current method.
Re: [2005] Logging error locations
Perfect! Thanks mate - getting exactly what I need now...