exceptions handle when connection or response fails

I have added a try-except statement in order to control response when connection o response fails