Exception: JS::Error

Inherits:
StandardError
  • Object
show all
Defined in:
ext/js/lib/js.rb,
ext/js/js-core.c

Overview

A wrapper class for JavaScript Error to allow the Error to be thrown in Ruby.

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ Error

Returns a new instance of Error.



222
223
224
225
# File 'ext/js/lib/js.rb', line 222

def initialize(exception)
  @exception = exception
  super
end

Instance Method Details

#messageObject



227
228
229
230
231
232
233
234
235
# File 'ext/js/lib/js.rb', line 227

def message
  stack = @exception[:stack]
  if stack.typeof == "string"
    # Error.stack contains the error message also
    stack.to_s
  else
    @exception.to_s
  end
end