Fix http error handling