Return an error object on connection failure

Fixes #9.
Merge pull request #10 from kevva/err

Return an error object on connection failure