diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-19 15:24:24 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-19 15:24:39 -0700 |
| commit | c1cec2ac8487bf7486b1ab85d24252d6658b3dfc (patch) | |
| tree | e81ad65b5c6441141a430edb32935b341d838795 /error_handling.moon | |
| parent | 7deed5af411689f198ebec5338476a563cb7ef28 (diff) | |
Tidying up error handling and REPL.
Diffstat (limited to 'error_handling.moon')
| -rw-r--r-- | error_handling.moon | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/error_handling.moon b/error_handling.moon index d932b91..c95556b 100644 --- a/error_handling.moon +++ b/error_handling.moon @@ -32,7 +32,7 @@ debug.getinfo = (thread,f,what)-> info.short_src = info.source\match('@([^[]*)') or info.short_src return info -print_err_msg = (error_message, stack_offset=3)-> +print_error = (error_message, stack_offset=3)-> io.stderr\write("#{colored.red "ERROR:"} #{colored.bright colored.red (error_message or "")}\n") io.stderr\write("stack traceback:\n") @@ -120,11 +120,11 @@ print_err_msg = (error_message, stack_offset=3)-> io.stderr\flush! -err_hand = (error_message)-> - print_err_msg error_message +error_handler = (error_message)-> + print_error error_message os.exit(false, true) -safe_run = (fn)-> - xpcall(fn, err_hand) +run_safely = (fn)-> + xpcall(fn, error_handler) -return safe_run +return {:run_safely, :print_error, :error_handler} |
