Return an error instead of panicking when a connection can't be made.