Error handling when the connection fails. #6

Pull request according to the issue I submitted earlier.
I've just added a simple error throwing to avoid the app to crashes.
I'm not actually aware of the best practises to throw error so might need to correct accordingly.
Thanks