From 6a65e76fc615bd10c21776bd4c4455ab522d2f29 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 21 Mar 2016 09:50:52 +0100 Subject: util.sql: Catch errors from LuaDBI connect (Fixes #568) --- util/sql.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util') 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; -- cgit v1.2.3