Error handling in http request method