Lost i2c signal, Arduino stuck

I would fix the connector. But if you can't, take a look at how the I2C scanner program for Arduino works. It tries to communicate with a device at a given address and if no answer is received, moves on. You could adopt that approach.