### Home Classes Methods

### In Files

- lib/v8/error.rb

### Parent

StandardError

### Namespace

- MODULE V8::Error::Protect
- MODULE V8::Error::Try

### Methods

- ::new
- #backtrace
- #bilingual_backtrace
- #causes
- #in_javascript?
- #in_ruby?
- #root_cause
- #standard_error_backtrace

### Included Modules

- Enumerable

### Files

- Makefile

### Class/Module Index

Quicksearch

- V8
- V8::Access
- V8::Access::Indices
- V8::Access::Invocation
- V8::Access::Invocation::Aritize
- V8::Access::Invocation::Method
- V8::Access::Invocation::Proc
- V8::Access::Invocation::UnboundMethod
- V8::Access::Names
- V8::Array
- V8::C
- V8::Conversion
- V8::Conversion::Accessor
- V8::Conversion::Array
- V8::Conversion::Class
- V8::Conversion::Code
- V8::Conversion::Code::InvocationHandler
- V8::Conversion::Constructor
- V8::Conversion::Constructor::Args
- V8::Conversion::Fixnum
- V8::Conversion::Fundamental
- V8::Conversion::Get
- V8::Conversion::Hash
- V8::Conversion::IGet
- V8::Conversion::ISet
- V8::Conversion::Identity
- V8::Conversion::Method
- V8::Conversion::Method::MethodCache
- V8::Conversion::NativeDate
- V8::Conversion::NativeObject
- V8::Conversion::NativeString
- V8::Conversion::Object
- V8::Conversion::Primitive
- V8::Conversion::Proc
- V8::Conversion::Reference
- V8::Conversion::Set
- V8::Conversion::String
- V8::Conversion::Symbol
- V8::Conversion::Time
- V8::Error
- V8::Error::Protect
- V8::Error::Try
- V8::Function
- V8::Object
- V8::StackFrame
- V8::StackTrace
- V8::Weak
- V8::Weak::Cell
- V8::Weak::Cell::Storage
- V8::Weak::Ref
- V8::Weak::WeakValueMap
- Object
- UnboundMethod

No matching classes.

# V8::Error

### Attributes

cause[R]

@!attribute [r] cause @return [Exception] the underlying error (if any) that triggered this error to be raised

javascript_backtrace[R]

@!attribute [r] javascript_backtrace @return [V8::StackTrace] the complete JavaScript stack at the point this error was thrown

value[R]

@!attribute [r] value @return [Object] the JavaScript value passed to the `throw` statement

### Public Class Methods

new(message, value, javascript_backtrace, cause = nil) click to toggle source

    # File lib/v8/error.rb, line 24
    def initialize(message, value, javascript_backtrace, cause = nil)
      super(message)
      @value = value
      @cause = cause
      @javascript_backtrace = javascript_backtrace
    end

### Public Instance Methods

backtrace(*modifiers) click to toggle source

    # File lib/v8/error.rb, line 41
    def backtrace(*modifiers)
      return unless super()
      trace_framework = modifiers.include?(:framework)
      trace_ruby = modifiers.length == 0 || modifiers.include?(:ruby)
      trace_javascript = modifiers.length == 0 || modifiers.include?(:javascript)
      bilingual_backtrace(trace_ruby, trace_javascript).tap do |trace|
        trace.reject! {|frame| frame =~  %{(lib/v8/.*\.rb|ext/v8/.*\.cc)}} unless modifiers.include?(:framework)
      end
    end

Also aliased as: standard_error_backtrace
bilingual_backtrace(trace_ruby = true, trace_javascript = true) click to toggle source

    # File lib/v8/error.rb, line 63
    def bilingual_backtrace(trace_ruby = true, trace_javascript = true)
      backtrace = causes.reduce(:backtrace => [], :ruby => -1, :javascript => -1) { |accumulator, cause|
        accumulator.tap do
          if trace_ruby
            backtrace_selector = cause.respond_to?(:standard_error_backtrace) ? :standard_error_backtrace : :backtrace
            ruby_frames = cause.send(backtrace_selector)[0..accumulator[:ruby]]
            accumulator[:backtrace].unshift *ruby_frames
            accumulator[:ruby] -= ruby_frames.length
          end
          if trace_javascript && cause.respond_to?(:javascript_backtrace)
            javascript_frames = cause.javascript_backtrace.to_a[0..accumulator[:javascript]].map(&:to_s)
            accumulator[:backtrace].unshift *javascript_frames
            accumulator[:javascript] -= javascript_frames.length
          end
        end
      }[:backtrace]
    end

causes() click to toggle source

    # File lib/v8/error.rb, line 31
    def causes
      [].tap do |causes|
        current = self
        until current.nil? do
          causes.push current
          current = current.respond_to?(:cause) ? current.cause : nil
        end
      end
    end

in_javascript?() click to toggle source

    # File lib/v8/error.rb, line 55
    def in_javascript?
      causes.last.is_a? self.class
    end

in_ruby?() click to toggle source

    # File lib/v8/error.rb, line 59
    def in_ruby?
      !in_javascript?
    end

root_cause() click to toggle source

    # File lib/v8/error.rb, line 51
    def root_cause
      causes.last
    end

standard_error_backtrace(*modifiers) click to toggle source

keep an alias to the StandardError#backtrace method so that we can capture just ruby backtrace frames

Alias for: backtrace

[Validate]

Generated with the Darkfish Rdoc Generator 2.