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

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -