File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -246,6 +246,10 @@ def convert_js_to_ruby(value)
246246 js_map_to_hash ( value )
247247 elsif map_iterator? ( value )
248248 value . map { |e | convert_js_to_ruby ( e ) }
249+ elsif Polyglot ::ForeignException === value
250+ exc = MiniRacer ::ScriptError . new ( value . message )
251+ exc . set_backtrace ( value . backtrace )
252+ exc
249253 else
250254 object = value
251255 h = { }
Original file line number Diff line number Diff line change @@ -1152,10 +1152,16 @@ def test_termination_exception
11521152 def test_ruby_exception
11531153 context = MiniRacer ::Context . new
11541154 context . attach ( "test" , proc { raise "boom" } )
1155+ line = __LINE__ - 1
11551156 actual = context . eval ( "try { test() } catch (e) { e }" )
11561157 assert_equal ( actual . class , MiniRacer ::ScriptError )
11571158 assert_equal ( actual . message , "boom" )
1158- assert_equal ( actual . backtrace , [ "JavaScript Error: boom" , "JavaScript at <eval>:1:7" ] )
1159+ if RUBY_ENGINE == "truffleruby"
1160+ assert_includes ( actual . backtrace [ 0 ] , "#{ __FILE__ } :#{ line } " )
1161+ assert_includes ( actual . backtrace [ 0 ] , "block in MiniRacerTest#test_ruby_exception" )
1162+ else
1163+ assert_equal ( actual . backtrace , [ "JavaScript Error: boom" , "JavaScript at <eval>:1:7" ] )
1164+ end
11591165 end
11601166
11611167 def test_large_integer
You can’t perform that action at this time.
0 commit comments