ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: elastic.lua checkReturn() does not properly check return code
Date Wed, 09 Nov 2016 21:51:31 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 7302670e9 -> 39132638d


elastic.lua checkReturn() does not properly check return code

This fixes #236

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/39132638
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/39132638
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/39132638

Branch: refs/heads/master
Commit: 39132638dd64e58d627124b36f7734563e1d1241
Parents: 7302670
Author: Sebb <sebb@apache.org>
Authored: Wed Nov 9 18:23:09 2016 +0000
Committer: Sebb <sebb@apache.org>
Committed: Wed Nov 9 18:23:09 2016 +0000

----------------------------------------------------------------------
 site/api/lib/elastic.lua | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/39132638/site/api/lib/elastic.lua
----------------------------------------------------------------------
diff --git a/site/api/lib/elastic.lua b/site/api/lib/elastic.lua
index 36745cd..b182970 100644
--- a/site/api/lib/elastic.lua
+++ b/site/api/lib/elastic.lua
@@ -26,14 +26,15 @@ local default_doc = "mbox"
 -- N.B. if the index is closed, ES returns 403, but that may perhaps be true for other conditions
 -- ES returns 404 if the index is missing.
 function checkReturn(code)
-    if not code or code == "closed" then
-        -- code is called by top-level functions only, so level 3 is the external caller
-        error("Could not contact database backend!", 3)
-    else -- we have a valid code
+    if type(code) == "number" then -- we have a valid HTTP status code
+        -- ignore expected return codes here
         -- index returns 201 when an entry is created
         if code ~= 200 and code ~= 201 then
+            -- code is called by top-level functions only, so level 3 is the external caller
             error("Backend Database returned code " .. code .. "!", 3)
         end
+    else
+        error("Could not contact database backend: " .. code .. "!", 3)
     end
 end
 


Mime
View raw message