fix error handling on http errors