If you have got this question in your mind, then you are in right place.
vim -V20 2>&1 |tee
You can give the debugfile as any file, where you would want to log the debug messages. This will log a lot of information in the debugfile, you can open the file, once you have got the error in the main vim window. After this, you can open the debugfile and simply search for the error that you were getting. Just look for the reason why this error is originated in the debug logs and then it should be pretty simple to fix that.