Firstly, you shouldn't do Dev work on production environment, you should test everything on a test environment before publishing your changes on production, you shouldn't change ref counters manually, bla bla bla... =)
Ok, I am sorry for being annoying. I will try your suggestion to reproduce the error to get some feeling how the error handling works in this case.
I have some ideas about DB control properties like ScriptTrace or LogErrors but I have to check it first.