Handled errors occurred in Connection and forced the object to emit the 'error' message such that the caller can handle when an error occurs.
Added the test.
Merge pull request #193 from shiroyuki/patch-1

Properly handle connection errors