c# - Can you get Method name that threw Exception? -


is there c# method returns upper-most caller, name of my method threw exception, if actual exception thrown (e.g. database driver errors when method calls it) ?

caller -> mymethod -> dbdriver(error)

i want "mymethod", not "dbdriver"

i'd rather not re-throw exceptions way chain.

my current kludge, iterate through stacktrace frames, , parse out method using methodbase.getcurrentmethod().declaringtype.

is there built-in method information or more elegant solution?

thanks!

use exception.targetsite property method name

gets method throws current exception.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -