aboutsummaryrefslogtreecommitdiff
path: root/error_handling.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-19 15:24:24 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-19 15:24:39 -0700
commitc1cec2ac8487bf7486b1ab85d24252d6658b3dfc (patch)
treee81ad65b5c6441141a430edb32935b341d838795 /error_handling.lua
parent7deed5af411689f198ebec5338476a563cb7ef28 (diff)
Tidying up error handling and REPL.
Diffstat (limited to 'error_handling.lua')
-rw-r--r--error_handling.lua22
1 files changed, 13 insertions, 9 deletions
diff --git a/error_handling.lua b/error_handling.lua
index 5cf54e5..3ead904 100644
--- a/error_handling.lua
+++ b/error_handling.lua
@@ -49,8 +49,8 @@ debug.getinfo = function(thread, f, what)
end
return info
end
-local print_err_msg
-print_err_msg = function(error_message, stack_offset)
+local print_error
+print_error = function(error_message, stack_offset)
if stack_offset == nil then
stack_offset = 3
end
@@ -194,13 +194,17 @@ print_err_msg = function(error_message, stack_offset)
end
return io.stderr:flush()
end
-local err_hand
-err_hand = function(error_message)
- print_err_msg(error_message)
+local error_handler
+error_handler = function(error_message)
+ print_error(error_message)
return os.exit(false, true)
end
-local safe_run
-safe_run = function(fn)
- return xpcall(fn, err_hand)
+local run_safely
+run_safely = function(fn)
+ return xpcall(fn, error_handler)
end
-return safe_run
+return {
+ run_safely = run_safely,
+ print_error = print_error,
+ error_handler = error_handler
+}