There should be a function (or maybe code to be called with source) to be run every time the an error is catch. And all 'continue's and warning inside the big loop should be replaced by an error since they are inside a try block now.
And instead of having the code at the end of the loop to clear the variables, replicated in al those places, a function would be better to manage.