|Debugging methodology - there are others though.
Start removing or commenting out code until the error goes away. Obviously you must give some thought to exactly which code you do this to.
Then when the error goes away you have found the problem.
Then you can create a much smaller example code to test that functionality and figure out how to make it work correctly. Then you fix the original code and put everything else back.