Class: WebkitRemote::Client::StackTrace

Inherits:
Object
  • Object
show all
Defined in:
lib/webkit_remote/client/runtime.rb

Overview

The call stack that represents the context of an assertion or error.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_stack_trace) ⇒ StackTrace

Parses a StackTrace object returned by a RPC request.

Parameters:

  • raw_stack_trace (Array<String, Object>)

    the raw StackTrace object in the Runtime domain returned by an RPC request



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/webkit_remote/client/runtime.rb', line 511

def initialize(raw_stack_trace)
  @description = raw_stack_trace['description']
  @frames = raw_stack_trace['callFrames'].map do |raw_frame|
    frame = {}
    if raw_frame['columnNumber']
      frame[:column] = raw_frame['columnNumber'].to_i
    end
    if raw_frame['lineNumber']
      frame[:line] = raw_frame['lineNumber'].to_i
    end
    if raw_frame['functionName']
      frame[:function] = raw_frame['functionName']
    end
    if raw_frame['url']
      frame[:url] = raw_frame['url']
    end
    frame
  end

  parent_trace = raw_stack_trace['parent']
  if parent_trace
    @parent = StackTrace.new parent_trace
  else
    @parent = nil
  end
end

Instance Attribute Details

#descriptionString (readonly)

Returns label of the trace; for async traces, might be the name of a function that initiated the async call.

Returns:

  • (String)

    label of the trace; for async traces, might be the name of a function that initiated the async call



540
541
542
# File 'lib/webkit_remote/client/runtime.rb', line 540

def description
  @description
end

#framesArray<Symbol, Object> (readonly)

Returns Ruby-friendly stack trace.

Returns:

  • (Array<Symbol, Object>)

    Ruby-friendly stack trace



543
544
545
# File 'lib/webkit_remote/client/runtime.rb', line 543

def frames
  @frames
end

#parentWebkitRemote::Client::StackTrace (readonly)

Returns stack trace for a parent async call; may be null.

Returns:



547
548
549
# File 'lib/webkit_remote/client/runtime.rb', line 547

def parent
  @parent
end

Class Method Details

.parse(raw_stack_trace) ⇒ WebkitRemote::Client::StackTrace

Parses a StackTrace object returned by a RPC request.

Parameters:

  • raw_stack_trace (Array<String, Object>)

    the raw StackTrace object in the Runtime domain returned by an RPC request

Returns:



554
555
556
557
558
# File 'lib/webkit_remote/client/runtime.rb', line 554

def self.parse(raw_stack_trace)
  return nil unless raw_stack_trace

  StackTrace.new raw_stack_trace
end