Sha256: 983c1d1a2d4bcf84633f74757e2a0807e276da7e64865803e6c1f9a59fe02060

Contents?: true

Size: 823 Bytes

Versions: 6

Compression:

Stored size: 823 Bytes

Contents

module V8
  class Portal
    class Caller
      
      def initialize(portal)
        @portal = portal
      end
      
      def raw
        yield
      rescue Exception => e
        case e
        when SystemExit, NoMemoryError
          raise e
        else
          error = V8::C::Exception::Error(V8::C::String::New(e.message))
          #TODO: This is almost certainly a crash here.
          #we need to hold onto `error` while it bubbles up the javascript stack.
          error.SetHiddenValue("TheRubyRacer::Cause", C::External::New(e))
          V8::C::ThrowException(error)
        end
      end

      def protect(*args, &block)
        @portal.v8 raw(*args, &block)
      end

      def invoke(code, *args, &block)
        protect do
          code.call(*args, &block)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
therubyracer-0.9.10 lib/v8/portal/caller.rb
therubyracer-0.9.9 lib/v8/portal/caller.rb
therubyracer-0.9.8 lib/v8/portal/caller.rb
therubyracer-0.9.7 lib/v8/portal/caller.rb
therubyracer-0.9.6 lib/v8/portal/caller.rb
therubyracer-0.9.5 lib/v8/portal/caller.rb