From 5a99a24176d9dd2cea3d802989b47d55bd89e932 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 18 Jan 2019 20:46:04 -0800 Subject: Better error handling. --- lib/core/errors.nom | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/core/errors.nom b/lib/core/errors.nom index 8027228..a84b580 100644 --- a/lib/core/errors.nom +++ b/lib/core/errors.nom @@ -25,7 +25,7 @@ use "core/control_flow" local _a, _b = \($a as lua expr), \($b as lua expr) if _a ~= _b then at_1_fail(\(quote "\($a.source)"), - "Assumption failed: This value was "..tostring(_a).." when it was supposed to be "..tostring(_b)..".") + "Assumption failed: This value was "..tostring(_a).." but it was expected to be "..tostring(_b)..".") end end ") @@ -35,7 +35,7 @@ use "core/control_flow" local _a, _b = \($a as lua expr), \($b as lua expr) if _a == _b then at_1_fail(\(quote "\($a.source)"), - "Assumption failed: This value was "..tostring(_a).." when it wasn't supposed to be.") + "Assumption failed: This value was "..tostring(_a).." but it wasn't expected to be.") end end ") @@ -76,10 +76,10 @@ test: Lua (" do local _fell_through = false - local _result = {pcall(function() + local _result = {xpcall(function() \($action as lua) _fell_through = true - end)} + end, enhance_error)} if _result[1] then \$success_lua else @@ -123,10 +123,10 @@ test: (do $action then always $final_action) compiles to (" do -- do/then always local _fell_through = false - local _results = {pcall(function() + local _results = {xpcall(function() \($action as lua) _fell_through = true - end)} + end, enhance_error)} \($final_action as lua) if not _results[1] then error(_results[2], 0) end if not _fell_through then return table.unpack(_results, 2) end -- cgit v1.2.3