Fix error reporting for insane hostnames.

If you put some really silly values in (e.g. /) into hostnames then
the error message s super super cryptic.

This patch fixes that, so it's at least obvious what / where / why it's
failing if you use --trace --debug