Gracefully handle HTTP errors with promises