How to trace an error to a line in my custom code

Give this a shot

This will allow you write out a trace on your code every so often and see how far the code executes.