Better behavior for failed connections in `brew search`

Fixes #20868.