mod_storage_sql2: Improve logging when database read fails
authorMatthew Wild <mwild1@gmail.com>
Wed, 24 Jun 2015 22:56:50 +0100
changeset 6741 845bc5ba306d
parent 6740 9f932a31eeba
child 6742 6216743c188c
mod_storage_sql2: Improve logging when database read fails
plugins/mod_storage_sql2.lua
--- a/plugins/mod_storage_sql2.lua	Wed Jun 24 22:55:41 2015 +0100
+++ b/plugins/mod_storage_sql2.lua	Wed Jun 24 22:56:50 2015 +0100
@@ -199,8 +199,11 @@
 function keyval_store:get(username)
 	user, store = username, self.store;
 	local ok, result = engine:transaction(keyval_store_get);
-	if not ok then return ok, result; end
-	return result;
+	if not ok then
+		module:log("error", "Unable to read from database %s store for %s: %s", store, username or "<host>", result);
+		return nil, result;
+	end
+	return result;	
 end
 function keyval_store:set(username, data)
 	user,store = username,self.store;