We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents e6db400 + 4cb60fa commit 610e88aCopy full SHA for 610e88a
lib/execjs/graaljs_runtime.rb
@@ -46,16 +46,18 @@ def call(source, *args)
46
47
private
48
49
+ ForeignException = defined?(Polyglot::ForeignException) ? Polyglot::ForeignException : ::RuntimeError
50
+
51
def translate
52
convert_js_to_ruby yield
- rescue ::RuntimeError => e
53
+ rescue ForeignException => e
54
if e.message.start_with?('SyntaxError:')
55
error_class = ExecJS::RuntimeError
56
else
57
error_class = ExecJS::ProgramError
58
end
59
- backtrace = e.backtrace.map { |line| line.sub('(eval)', '(execjs)') }
60
+ backtrace = (e.backtrace || []).map { |line| line.sub('(eval)', '(execjs)') }
61
raise error_class, e.message, backtrace
62
63
0 commit comments