fix exception if response is not successful

Got it. Thanks