strip macro line numbers

This commit is contained in:
Mike J Innes 2017-03-12 18:33:02 +00:00
parent 418f5bfe28
commit 06e9626c0b

View File

@ -91,6 +91,7 @@ end
# Error Handling # Error Handling
using Juno using Juno
using MacroTools: @q
Juno.errmsg(e::mx.MXError) = e.msg Juno.errmsg(e::mx.MXError) = e.msg
function errnode(e::mx.MXError) function errnode(e::mx.MXError)
@ -102,12 +103,12 @@ end
striptrace(e::mx.MXError) = mx.MXError(split(e.msg, "\n")[1]) striptrace(e::mx.MXError) = mx.MXError(split(e.msg, "\n")[1])
macro mxerr(stk, ex) macro mxerr(stk, ex)
:(try @q try
$(esc(ex)) $(esc(ex))
catch e catch e
(isa(e, mx.MXError) && (node = errnode(e)) != nothing) || rethrow() (isa(e, mx.MXError) && (node = errnode(e)) != nothing) || rethrow()
stk = $(esc(stk)) stk = $(esc(stk))
haskey(stk, node) || rethrow() haskey(stk, node) || rethrow()
throw(Exception(striptrace(e), totrace(stk[node]))) throw(Exception(striptrace(e), totrace(stk[node])))
end) end
end end