aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-21 12:00:17 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-21 12:28:38 +0000
commitf5776f95ea3ae5b76c12cca96c00914f5d43eed0 (patch)
treed544acd4f2d08d4bab8bc8a7fe2c539d4af713e4 /core
parentlanguage Error tracking (diff)
downloadalive-f5776f95ea3ae5b76c12cca96c00914f5d43eed0.tar.gz
alive-f5776f95ea3ae5b76c12cca96c00914f5d43eed0.zip
luajit compatibility
Diffstat (limited to 'core')
-rw-r--r--core/builtin.moon2
-rw-r--r--core/error.moon15
2 files changed, 13 insertions, 4 deletions
diff --git a/core/builtin.moon b/core/builtin.moon
index 3e4787c..49de80f 100644
--- a/core/builtin.moon
+++ b/core/builtin.moon
@@ -214,7 +214,7 @@ prints expr's value whenever it changes."
op = Value 'opdef', traceOp
tag = @tag\clone Tag.parse '-1'
- prefix = Value.str tail[1]\stringify!
+ prefix = Value.str tostring tail[1]
op_invoke\eval_cell scope, tag, op, { prefix, tail[1] }
{
diff --git a/core/error.moon b/core/error.moon
index a06c359..e72cc5f 100644
--- a/core/error.moon
+++ b/core/error.moon
@@ -2,6 +2,9 @@
-- Language error and traceback.
--
-- @classmod Error
+
+unpack or= table.unpack
+
class Error
--- members
-- @section members
@@ -14,7 +17,13 @@ class Error
-- @tparam string where
add_frame: (where) => @trace ..= "\n while #{where}"
- __tostring: => "#{@kind} error: #{@message}#{@detail}#{@trace}"
+ __tostring: =>
+ str = "#{@kind} error: #{@message}"
+ if @detail
+ str ..= "\n#{@detail}"
+ if @trace
+ str ..= @trace
+ str
--- static functions
-- @section static
@@ -33,13 +42,13 @@ class Error
-- @tparam string message
-- @tparam ?string detail
new: (@kind, @message, @detail) =>
- @trace = ""
+ @trace = ''
handler = (err) ->
if err.__class == Error
err
else
- Error 'implementation', err, debug.traceback 'Lua error below:', 2
+ Error 'implementation', err, debug.traceback "Lua error below:", 2
--- Wrap function errors in a traceback frame.
--
-- Execute `fn(...)`, and turn any error thrown as a result into an