Added an error handler for connection errors