When you submit an InfoPath form which was opened from an existing form, so called Edit, it is hard to debug the managed code. The method that I use to resolve the problem is to put statements into the code I suspect. Just as the writelines in the early days developing without debugger. Instead of writelines I used the MessageBox.Show() command. This enabled me to pinpoint the error location.
Today I fixed a problem when submitting the InfoPath form which was caused by the fact that the file already existed in the SharePoint Document Library.
The solution was to enable a checkbox in the Data Connections of the InfoPath Form Template. Just as described in the weblogs below: