throw graph-aware exceptions

This commit is contained in:
Mike J Innes 2017-01-29 23:35:03 +05:30
parent 3981485500
commit 349e81172d

View File

@ -82,6 +82,9 @@ end
# Error Handling # Error Handling
using Juno
Juno.errmsg(e::mx.MXError) = e.msg
function errnode(e::mx.MXError) function errnode(e::mx.MXError)
m = match(r"Error in (\w+):", e.msg) m = match(r"Error in (\w+):", e.msg)
m == nothing && return m == nothing && return
@ -94,7 +97,6 @@ macro mxerr(stk, 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))
@show stk[node] throw(DataFlow.Exception(e, DataFlow.totrace(stk[node])))
rethrow()
end) end)
end end