better http error handling