Software /
code /
prosody
Changeset
4218:8a271b3fcaa7
mod_storage_sql: Display friendlier error when LuaDBI is missing
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 01 Mar 2011 06:12:43 +0000 |
parents | 4216:ff80a8471e86 |
children | 4219:bffce780999d 4220:05f4db0459b1 |
files | plugins/mod_storage_sql.lua |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua Sat Feb 26 00:23:48 2011 +0000 +++ b/plugins/mod_storage_sql.lua Tue Mar 01 06:12:43 2011 +0000 @@ -96,7 +96,18 @@ end do -- process options to get a db connection - DBI = require "DBI"; + local ok; + prosody.unlock_globals(); + ok, DBI = pcall(require, "DBI"); + if not ok then + package.loaded["DBI"] = {}; + module:log("error", "Failed to load the LuaDBI library for accessing SQL databases: %s", DBI); + module:log("error", "More information on installing LuaDBI can be found at http://prosody.im/doc/depends#luadbi"); + end + prosody.lock_globals(); + if not ok or not DBI.Connect then + return; -- Halt loading of this module + end params = params or { driver = "SQLite3" };