Improve connection exception handling