Properly handle connection errors

Handled errors occurred in Connection and forced the object to emit the 'error' message such that the caller can handle when an error occurs.