1
0
Fork 0
mirror of https://github.com/rubyjs/therubyrhino synced 2023-03-27 23:21:34 -04:00
therubyrhino/lib/rhino/error.rb

25 lines
484 B
Ruby

module Rhino
class JSError < StandardError
def initialize(native)
@native = native # NativeException wrapping a Java Throwable
end
# most likely a Rhino::JS::JavaScriptException
def cause
@native.respond_to?(:cause) ? @native.cause : nil
end
def message
cause ? cause.details : @native.to_s
end
def javascript_backtrace
cause.is_a?(JS::RhinoException) ? cause.getScriptStackTrace : nil
end
end
end