check if the connection was successful before assuming it was

now the error is set properly and the client can notify it