Skip to content

Commit

Permalink
Rescue runtime error for prism
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Feb 14, 2024
1 parent 80ede6b commit ac4101e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/error_highlight/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def self.spot(obj, **opts)

return nil unless Thread::Backtrace::Location === loc

node = RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
node =
begin
RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
rescue RuntimeError => error
# RubyVM::AbstractSyntaxTree.of raises an error with a message that
# includes "prism" when the ISEQ was compiled with the prism compiler.
# In this case, we'll set the node to `nil`. In the future, we will
# reparse with the prism parser and pass the parsed node to Spotter.
raise unless error.message.include?("prism")
end

Spotter.new(node, **opts).spot

Expand Down

0 comments on commit ac4101e

Please sign in to comment.