From 067267c313e2b6f30472803d6ad77b5d28d82441 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 27 Nov 2016 20:28:53 -0800 Subject: [PATCH] allow Preproc to throw errors again --- lips/Preproc.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lips/Preproc.lua b/lips/Preproc.lua index 78308af..469b4d5 100644 --- a/lips/Preproc.lua +++ b/lips/Preproc.lua @@ -1,4 +1,5 @@ local abs = math.abs +local format = string.format local insert = table.insert local path = string.gsub(..., "[^.]+$", "") @@ -13,6 +14,13 @@ function Preproc:init(options) self.options = options or {} end +function Preproc:error(msg, got) + if got ~= nil then + msg = msg..', got '..tostring(got) + end + error(format('%s:%d: Error: %s', self.fn, self.line, msg), 2) +end + function Preproc:iter(statements) assert(statements) local i = 0