[Groonga-commit] groonga/grnci at 9008adb [master] Update DB.Load to return the result even if the response has an error.

Back to archive index

Susumu Yata null+****@clear*****
Thu Sep 14 17:40:45 JST 2017


Susumu Yata	2017-09-14 17:40:45 +0900 (Thu, 14 Sep 2017)

  New Revision: 9008adbe4cbd28d1e0b326fe2311e914b229aecc
  https://github.com/groonga/grnci/commit/9008adbe4cbd28d1e0b326fe2311e914b229aecc

  Message:
    Update DB.Load to return the result even if the response has an error.

  Modified files:
    v2/db.go

  Modified: v2/db.go (+7 -4)
===================================================================
--- v2/db.go    2017-09-14 17:27:46 +0900 (aed4a1e)
+++ v2/db.go    2017-09-14 17:40:45 +0900 (fb6f3f7)
@@ -495,20 +495,23 @@ func (db *DB) Load(tbl string, values io.Reader, options *DBLoadOptions) (int, e
 	// recvInt should not be used because a load command returns the result
 	// even if resp has an error.
 	defer resp.Close()
-	if err := resp.Err(); err != nil {
-		return 0, err
-	}
 	jsonData, err := ioutil.ReadAll(resp)
 	if err != nil {
+		if resp.Err() != nil {
+			return 0, resp.Err()
+		}
 		return 0, err
 	}
 	var result int
 	if err := json.Unmarshal(jsonData, &result); err != nil {
+		if resp.Err() != nil {
+			return 0, resp.Err()
+		}
 		return 0, NewError(ResponseError, "json.Unmarshal failed.", map[string]interface{}{
 			"error": err.Error(),
 		})
 	}
-	return result, nil
+	return result, resp.Err()
 }
 
 // appendRow appends the JSON-encoded row to buf nad returns the exetended buffer.
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170914/7a803f03/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index