Content deleted Content added
m Remove completed TODO item and convert assert(false) statements into straight-up error calls |
Removed some unnecessary error/assert statements, handled some errors more gracefully |
||
Line 3:
-- TODO:
-- Take out the
-- Functions with error statements in them:
-- getFullBookName
-- handleOD
-- getStandardWork (only throws an error if pre-conditions not met)
-- getLectureOrdinal (only called with pcall)
--[[
Line 156 ⟶ 161:
local function getFullBookName(bookParam)
Returns the full name of a book of scripture based on the name/abbrev./alias provided
Pre-condition: bookParam is non-nil
NB: Because both Matthew in the NT and JST Matthew have just the title
"Matthew" on Wikisource, this function returns "JST Matthew" as the full name
Line 163 ⟶ 170:
]]
local function getFullBookName(bookParam)
for title,bookList in pairs(standardWorks) do
if bookList[bookParam] then
Line 207 ⟶ 213:
returns the Standard Work (as titled by Wikisource) that contains the book
passed in.
Preconditions: bookName is non-nil and was returned by getFullBookName
]]
local function getStandardWork(
-- check the standardWorks table for any values that have a key with the
-- full name of the book; if so, return the key (the title of the SW)
for title,bookList in pairs(standardWorks) do
if bookList[
end
error("Book <" ..
-- pre-conditions mean that this error should never occur, aka if it does,
-- something went very wrong!
end
Line 268 ⟶ 272:
-- Special case for handling the Official Declarations in the D&C
local function handleOD(displayTextParam, decNumber)
if
else -- decNumber wasn't 1 or 2 (and could even be nil)
if decNumber then
error("No such Official Declaration: " .. decNumber, 0)
else
error("No
end
end
end
-- for when the user has provided either no parameters or just one (the display
-- text for the wikilink)
local function handleFewParams(displayTextParam)
if not displayTextParam then
Line 336 ⟶ 347:
end
-- pre-condition: lectureNum is non-nil
local function getLectureOrdinal(lectureNum)
if lectureNum == "1" then return "First"
Line 391 ⟶ 403:
if fullBookName == "Lectures on Faith" then
if chapterParam then
if status then
fullBookName = "Lecture " .. ordinal
else
fullBookName = nil -- just cite to LoF generally
chapterParam = chapterParam .. " (invalid)" -- so user knows there was a problem
mw.log(ordinal) -- print error message to debug console (?)
end
else
fullBookName = nil -- The user has not provided a chapter (lecture) so this is treated as wanting to cite the LoF generally
|