Software / code / prosody
Comparison
plugins/mod_storage_sql.lua @ 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 |
| parent | 4109:d26db1f936f8 |
| child | 4285:c806a599224a |
comparison
equal
deleted
inserted
replaced
| 4216:ff80a8471e86 | 4218:8a271b3fcaa7 |
|---|---|
| 94 end | 94 end |
| 95 end | 95 end |
| 96 end | 96 end |
| 97 | 97 |
| 98 do -- process options to get a db connection | 98 do -- process options to get a db connection |
| 99 DBI = require "DBI"; | 99 local ok; |
| 100 prosody.unlock_globals(); | |
| 101 ok, DBI = pcall(require, "DBI"); | |
| 102 if not ok then | |
| 103 package.loaded["DBI"] = {}; | |
| 104 module:log("error", "Failed to load the LuaDBI library for accessing SQL databases: %s", DBI); | |
| 105 module:log("error", "More information on installing LuaDBI can be found at http://prosody.im/doc/depends#luadbi"); | |
| 106 end | |
| 107 prosody.lock_globals(); | |
| 108 if not ok or not DBI.Connect then | |
| 109 return; -- Halt loading of this module | |
| 110 end | |
| 100 | 111 |
| 101 params = params or { driver = "SQLite3" }; | 112 params = params or { driver = "SQLite3" }; |
| 102 | 113 |
| 103 if params.driver == "SQLite3" then | 114 if params.driver == "SQLite3" then |
| 104 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); | 115 params.database = resolve_relative_path(prosody.paths.data or ".", params.database or "prosody.sqlite"); |