Return method name on exception

Hi all

I have Try Catches all through my code, but if and when an exception occurs, I'd like to return the class and method name that pulled the exception ...


            ...some code
        Catch ex As Exception
            Msg.Text = "This error occured in this class: " & currentClassName & " and this method: " & currentMethodName & ex.Message
        End Try

Anyone got any ideas of how to make it happen in an automated fashion? ie. I don't want to MANUALLY go through each function and assign a variable to remember the name of the class and function.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is pretty easy to do. The Exception can tell you the name of the method:


To get the name of the class, the only way I have found is to look at


and parse it to get what you want.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
msiedleAuthor Commented:
Beautiful! Thanks very much :-)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.