# HG changeset patch # User Kim Alvefur # Date 1458918574 -3600 # Node ID a2dce746599bb6c81870543da2b4e71caaa022ca # Parent 4fd984d1e445d333f2f281ca30618be87ba58233 util.sql: Log errors in transaction to error level with traceback but return only error message (fixes #464) diff -r 4fd984d1e445 -r a2dce746599b util/sql.lua --- a/util/sql.lua Wed Mar 23 23:21:03 2016 +0100 +++ b/util/sql.lua Fri Mar 25 16:09:34 2016 +0100 @@ -202,6 +202,10 @@ 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 @@ 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));