Diff

util/sql.lua @ 7317:a2dce746599b

util.sql: Log errors in transaction to error level with traceback but return only error message (fixes #464)
author Kim Alvefur <zash@zash.se>
date Fri, 25 Mar 2016 16:09:34 +0100
parent 7312:b4e99602ae75
child 7428:f791651ee334
line wrap: on
line diff
--- 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));