Add a types module to help refactor type checking

Type checking will be performed in unit tests, but will be an
empty function at runtime.
This commit is contained in:
Robin Malley 2022-06-26 23:08:46 +00:00
parent 647e7f2ac2
commit ec6aed9866
2 changed files with 6 additions and 2 deletions

View File

@ -44,4 +44,8 @@ function types.matches_pattern(pattern)
end
end
function types.check(...)
end
return types

View File

@ -1,14 +1,14 @@
local sql = require("lsqlite3")
local config = require("config")
local types = require("types")
local util = {}
--[[
Runs an sql query and receives the 3 arguments back, prints a nice error
message on fail, and returns true on success.
]]
function util.sqlassert(...)
local r,errcode,err = ...
function util.sqlassert(r, errcode, err)
if not r then
error(string.format("%d: %s",errcode, err))
end