Skip to content

Commit

Permalink
fixed mongodb werror return errmsg (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi authored Dec 8, 2020
1 parent 7041942 commit 4faa649
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lualib/skynet/db/mongo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4faa649

Please sign in to comment.