aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-03-21 09:50:52 +0100
committerKim Alvefur <zash@zash.se>2016-03-21 09:50:52 +0100
commitc00adb21f49071216704b0c304da2fb4f52f81d4 (patch)
treeb0acc90f74a7e8e23a10d7322a976b4f5650ba7e /util
parentc42992594da7b524f633894841fca8791d9f55a1 (diff)
downloadprosody-c00adb21f49071216704b0c304da2fb4f52f81d4.tar.gz
prosody-c00adb21f49071216704b0c304da2fb4f52f81d4.zip
util.sql: Catch errors from LuaDBI connect (Fixes #568)
Diffstat (limited to 'util')
-rw-r--r--util/sql.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/sql.lua b/util/sql.lua
index dcf665fb..f64e8e10 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -102,11 +102,12 @@ function engine:connect()
local params = self.params;
assert(params.driver, "no driver")
log("debug", "Connecting to [%s] %s...", params.driver, params.database);
- local dbh, err = DBI.Connect(
+ local ok, dbh, err = pcall(DBI.Connect,
params.driver, params.database,
params.username, params.password,
params.host, params.port
);
+ if not ok then return ok, dbh; end
if not dbh then return nil, err; end
dbh:autocommit(false); -- don't commit automatically
self.conn = dbh;