From 4faa6499e819e4b5463d0b1efda7cf9d9f6dabcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Tue, 8 Dec 2020 08:47:14 +0800 Subject: [PATCH] fixed mongodb werror return errmsg (#1271) --- lualib/skynet/db/mongo.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lualib/skynet/db/mongo.lua b/lualib/skynet/db/mongo.lua index 42dd9eee..fd9e2c0c 100644 --- a/lualib/skynet/db/mongo.lua +++ b/lualib/skynet/db/mongo.lua @@ -333,14 +333,16 @@ function mongo_collection:insert(doc) end local function werror(r) - local ok = (r.ok == 1 and not r.writeErrors and not r.writeConcernError) + local ok = (r.ok == 1 and not r.writeErrors and not r.writeConcernError and not r.errmsg) local err if not ok then if r.writeErrors then err = r.writeErrors[1].errmsg - else + elseif r.writeConcernError then err = r.writeConcernError.errmsg + else + err = r.errmsg end end return ok, err, r