Error Reporting (best practice)

I use Dim DB As SQLiteDatabase in my Update Method and my SQLite database gets updated nicely. In this Method, every time I execute a SQL statement, I check: DB.Error. If it is true then I return the DB.ErrorMessage. This also works well.

I use this same Method in many places. But the DB.ErrorMessage only reports the SQL error. Leaving me with no clue which one of the many places called my Update Method. Which means, every time I call my Update Method, I also have to also check if an error message is being returned from my Update Method. And if so, generate a 2nd error message, indicating the origin.

Question: within my Update Method, is there any way to know where the call came from? Another Method? A button? If so, then I could combine all the information I need in in one Error Message instead of two.

check out currentmethod name
pass that in to your update method so you know who called it
thats the simply and easiest
there are ways to find who called you IF there is an error by raising an exception and then crawling the stack it generates but that can be troublesome and a lot slower

I’ve got this in a KM macro: #If DebugBuild Then System.Debuglog currentMethodName + ": "

Thanks Tanner! System.Debuglog Good to know about!