handle error in connect() call