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

25 lines
638 B
Ruby
Raw Normal View History

2012-06-14 23:34:38 -04:00
module V8
class Error < StandardError
attr_reader :value
def initialize(message, value)
super(message)
@value = value
end
end
2012-06-16 09:33:31 -04:00
const_set :JSError, Error
2012-06-14 23:34:38 -04:00
def self.Error(exception)
value = exception.to_ruby
if !exception.kind_of?(V8::C::Value)
raise V8::Error.new(exception.to_s, value)
elsif exception.IsNativeError()
if football = exception.GetHiddenValue("rr::Football")
raise football.Value()
else
raise V8::Error.new(exception.Get("message").to_ruby, value)
end
else
raise V8::Error.new(exception.ToString().to_ruby, value)
end
end
end