exceptions handle when connection or response fails

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