Skip to content

Commit

Permalink
Enclose signatures_at in try/catch (fixes #132)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Mar 13, 2019
1 parent 02a8d3c commit 7454432
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,15 @@ end
Set a breakpoint at the specified file and line number.
"""
function breakpoint(filename::AbstractString, line::Integer, args...)
sigs = signatures_at(filename, line)
local sigs
try
sigs = signatures_at(filename, line)
catch
sigs = nothing
end
if sigs === nothing
# TODO: build a Revise-free fallback. Note this won't work well for methods with keywords.
error("no signatures found at $filename, $line. Restarting and `using Revise` may fix this problem.")
error("no signatures found at $filename, $line.\nRestarting and `using Revise` and the relevant package may fix this problem.")
end
for sig in sigs
method = JuliaInterpreter.whichtt(sig)
Expand Down
7 changes: 7 additions & 0 deletions test/breakpoints.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ end
var = JuliaInterpreter.locals(leaf(frame))
@test !any(v->v.name == :b, var)
@test filter(v->v.name == :a, var)[1].value == 2
else
try
breakpoint(pathof(JuliaInterpreter.CodeTracking), 5)
catch err
@test isa(err, ErrorException)
@test occursin("Revise", err.msg)
end
end

# Direct return
Expand Down

0 comments on commit 7454432

Please sign in to comment.