Skip to content

Commit

Permalink
method_name(bt): skip over "macro expansion" when looking for method …
Browse files Browse the repository at this point in the history
…name in calls stack
  • Loading branch information
samoconnor committed Oct 1, 2018
1 parent 512709b commit e0fe578
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,17 @@ sprintcompact(x) = sprint(show, x; context=:compact => true)
printlncompact(x) = println(sprintcompact(x))


method_name(bt) = sprint(StackTraces.show_spec_linfo,
first(StackTraces.lookup(first(bt))))
function method_name(bt)
for f in bt
for i in StackTraces.lookup(f)
n = sprint(StackTraces.show_spec_linfo, i)
if n != "macro expansion"
return n
end
end
end
return "unknown method"
end

@noinline function precondition_error(msg, bt)
msg = string(method_name(bt), " requires ", msg)
Expand Down

0 comments on commit e0fe578

Please sign in to comment.