Fix incorrect handling of HTTPError