Bình thường chúng ta có thể return error như sau:
res, err := indexReq.Do(ctx, eei.elasticEngine.EE) if err != nil { log.Error(err.Error()) return err }
Next, you’ll adjust the error handling portion. If res.IsError()
evaluates to true, instead of logging the error and continuing, you’ll return an error:
if res.IsError() { return fmt.Errorf("Error indexing document: %s", res.String()) } else { // ... rest of the success logic ... }