mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Merge pull request #112 from eregon/foreign_exception_fixes
Adapt ExecJS::GraalJSRuntime to foreign exception changes in TruffleRuby
This commit is contained in:
commit
610e88a9ce
1 changed files with 4 additions and 2 deletions
|
@ -46,16 +46,18 @@ module ExecJS
|
|||
|
||||
private
|
||||
|
||||
ForeignException = defined?(Polyglot::ForeignException) ? Polyglot::ForeignException : ::RuntimeError
|
||||
|
||||
def translate
|
||||
convert_js_to_ruby yield
|
||||
rescue ::RuntimeError => e
|
||||
rescue ForeignException => e
|
||||
if e.message.start_with?('SyntaxError:')
|
||||
error_class = ExecJS::RuntimeError
|
||||
else
|
||||
error_class = ExecJS::ProgramError
|
||||
end
|
||||
|
||||
backtrace = e.backtrace.map { |line| line.sub('(eval)', '(execjs)') }
|
||||
backtrace = (e.backtrace || []).map { |line| line.sub('(eval)', '(execjs)') }
|
||||
raise error_class, e.message, backtrace
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue