diff options
author | Kim Alvefur <zash@zash.se> | 2016-03-25 16:09:34 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2016-03-25 16:09:34 +0100 |
commit | 935e3cce462a650a95208dbdfa11aad5409c2547 (patch) | |
tree | 25e38aca4c34085e904b69cb1e7e4305394788f8 | |
parent | 921c69533820f54eea04a84f043eddb156482f92 (diff) | |
download | prosody-935e3cce462a650a95208dbdfa11aad5409c2547.tar.gz prosody-935e3cce462a650a95208dbdfa11aad5409c2547.zip |
util.sql: Log errors in transaction to error level with traceback but return only error message (fixes #464)
-rw-r--r-- | util/sql.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util/sql.lua b/util/sql.lua index 657acb79..acdf9c63 100644 --- a/util/sql.lua +++ b/util/sql.lua @@ -202,6 +202,10 @@ function engine:debug(enable) engine.update = engine.execute_update; end end +local function handleerr(err) + log("error", "Error in SQL transaction: %s", debug_traceback(err, 3)); + return err; +end function engine:_transaction(func, ...) if not self.conn then local ok, err = self:connect(); @@ -212,7 +216,7 @@ function engine:_transaction(func, ...) local function f() return func(unpack(args, 1, n_args)); end log("debug", "SQL transaction begin [%s]", tostring(func)); self.__transaction = true; - local success, a, b, c = xpcall(f, debug_traceback); + local success, a, b, c = xpcall(f, handleerr); self.__transaction = nil; if success then log("debug", "SQL transaction success [%s]", tostring(func)); |