Made the code more robust on a http error.