aboutsummaryrefslogtreecommitdiff
path: root/error_handling.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:23 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-23 17:22:43 -0700
commit863983202ce4ef92d9e3a296a682535d157c245d (patch)
tree288411a534c8a64542ce1b101b9532cb12f11c7d /error_handling.lua
parent0d888db6324ecd879ba770880173255b6c3f7ae5 (diff)
Fixed up nomsupath behavior and refactored file stuff into its own file.
Diffstat (limited to 'error_handling.lua')
-rw-r--r--error_handling.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/error_handling.lua b/error_handling.lua
index 90c5991..b0e6dde 100644
--- a/error_handling.lua
+++ b/error_handling.lua
@@ -1,3 +1,4 @@
+local files = require("files")
local debug_getinfo = debug.getinfo
local ok, to_lua = pcall(function()
return require('moonscript.base').to_lua
@@ -97,7 +98,7 @@ print_error = function(error_message, stack_offset)
end
local filename, start, stop = calling_fn.source:match('@([^[]*)%[([0-9]+):([0-9]+)]')
assert(filename)
- local file = FILE_CACHE[filename]:sub(tonumber(start), tonumber(stop))
+ local file = read_file(filename):sub(tonumber(start), tonumber(stop))
local err_line = get_line(file, calling_fn.currentline):sub(1, -2)
local offending_statement = colored.bright(colored.red(err_line:match("^[ ]*(.*)")))
if calling_fn.name then
@@ -118,7 +119,7 @@ print_error = function(error_message, stack_offset)
else
local file
ok, file = pcall(function()
- return FILE_CACHE[calling_fn.short_src]
+ return read_file(calling_fn.short_src)
end)
if not ok then
file = nil