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
end end
function types.check(...)
end
return types return types

View File

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