From d5e264125994b6e5943ffb42f607362b3e79bcba Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 18 Jun 2023 03:30:14 +0100 Subject: improve error handling in db.lua --- server/db.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/db.lua b/server/db.lua index a4cd8a7..4a6e6d3 100644 --- a/server/db.lua +++ b/server/db.lua @@ -1,14 +1,14 @@ local lmdb = require'lmdb' -local env = lmdb.open('data',{maxdbs=16}) +local env = assert(lmdb.open('data',{maxdbs=16})) local function get_db(dbname, writeable) -- shortcut if writeable == nil then writeable = false end - local txn = assert(env:txn_begin(writeable),"couldn't begin txn") - local the_db = assert(txn:open(dbname), "couldn't open db") + local txn = assert(env:txn_begin(writeable)) + local the_db = assert(txn:open(dbname)) return txn,the_db end local function txn(writeable) - return assert(env:txn_begin(writeable), "couldn't begin txn") + return assert(env:txn_begin(writeable)) end -- cgit v1.2.3