connect.then handles error