improve http error handling