Class: GraphQL::Backtrace

Inherits:
Object
  • Object
show all
Extended by:
Delegate
Includes:
Enumerable
Defined in:
lib/graphql/backtrace.rb,
lib/graphql/backtrace/table.rb,
lib/graphql/backtrace/tracer.rb,
lib/graphql/backtrace/traced_error.rb,
lib/graphql/backtrace/inspect_result.rb

Overview

Wrap unhandled errors with TracedError.

TracedError provides a GraphQL backtrace with arguments and return values. The underlying error is available as TracedError#cause.

WARNING: Backtrace.enable is not threadsafe because Tracing.install is not threadsafe.

Examples:

toggling backtrace annotation

# to enable:
GraphQL::Backtrace.enable
# later, to disable:
GraphQL::Backtrace.disable

Defined Under Namespace

Modules: InspectResult, Tracer Classes: Table, TracedError

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Delegate

def_delegators

Constructor Details

#initialize(context, value: nil) ⇒ Backtrace

Returns a new instance of Backtrace.



36
37
38
# File 'lib/graphql/backtrace.rb', line 36

def initialize(context, value: nil)
  @table = Table.new(context, value: value)
end

Class Method Details

.disableObject



31
32
33
34
# File 'lib/graphql/backtrace.rb', line 31

def self.disable
  GraphQL::Tracing.uninstall(Backtrace::Tracer)
  nil
end

.enableObject



26
27
28
29
# File 'lib/graphql/backtrace.rb', line 26

def self.enable
  GraphQL::Tracing.install(Backtrace::Tracer)
  nil
end

Instance Method Details

#inspectObject Also known as: to_s



40
41
42
# File 'lib/graphql/backtrace.rb', line 40

def inspect
  @table.to_table
end

#to_aObject



46
47
48
# File 'lib/graphql/backtrace.rb', line 46

def to_a
  @table.to_backtrace
end