aboutsummaryrefslogtreecommitdiff
path: root/error_handling.moon
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.moon
parent0d888db6324ecd879ba770880173255b6c3f7ae5 (diff)
Fixed up nomsupath behavior and refactored file stuff into its own file.
Diffstat (limited to 'error_handling.moon')
-rw-r--r--error_handling.moon5
1 files changed, 3 insertions, 2 deletions
diff --git a/error_handling.moon b/error_handling.moon
index c71e782..5341348 100644
--- a/error_handling.moon
+++ b/error_handling.moon
@@ -1,4 +1,5 @@
-- This file contains the logic for making nicer error messages
+files = require "files"
debug_getinfo = debug.getinfo
export SOURCE_MAP
@@ -62,7 +63,7 @@ print_error = (error_message, stack_offset=3)->
--calling_fn.short_src = calling_fn.source\match('"([^[]*)')
filename,start,stop = calling_fn.source\match('@([^[]*)%[([0-9]+):([0-9]+)]')
assert(filename)
- file = FILE_CACHE[filename]\sub(tonumber(start),tonumber(stop))
+ file = read_file(filename)\sub(tonumber(start),tonumber(stop))
err_line = get_line(file, calling_fn.currentline)\sub(1,-2)
offending_statement = colored.bright(colored.red(err_line\match("^[ ]*(.*)")))
-- TODO: get name properly
@@ -73,7 +74,7 @@ print_error = (error_message, stack_offset=3)->
else "main chunk"
line = colored.yellow("#{filename}:#{calling_fn.currentline} in #{name}\n #{offending_statement}")
else
- ok, file = pcall ->FILE_CACHE[calling_fn.short_src]
+ ok, file = pcall ->read_file(calling_fn.short_src)
if not ok then file = nil
local line_num
if name == nil