Handle http response errors gracefully