Error handling for connection operation