diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/builtin.moon | 2 | ||||
| -rw-r--r-- | core/error.moon | 15 |
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 |
