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
Post a Comment