class GraphQL::Backtrace::TracedError
When {Backtrace} is enabled, raised errors are wrapped with {TracedError}.
Constants
- CAUSE_BACKTRACE_PREVIEW_LENGTH
This many lines of the original Ruby backtrace are included in the message
- MESSAGE_TEMPLATE
Attributes
context[R]
@return [GraphQL::Query::Context] The context at the field where the error was raised
graphql_backtrace[R]
@return [Array<String>] Printable backtrace of GraphQL
error context
Public Class Methods
new(err, current_ctx)
click to toggle source
Calls superclass method
# File lib/graphql/backtrace/traced_error.rb, line 28 def initialize(err, current_ctx) @context = current_ctx backtrace = Backtrace.new(current_ctx, value: err) @graphql_backtrace = backtrace.to_a cause_backtrace_preview = err.backtrace.first(CAUSE_BACKTRACE_PREVIEW_LENGTH).join("\n ") cause_backtrace_remainder_length = err.backtrace.length - CAUSE_BACKTRACE_PREVIEW_LENGTH cause_backtrace_more = if cause_backtrace_remainder_length < 0 "" elsif cause_backtrace_remainder_length == 1 "... and 1 more line\n" else "... and #{cause_backtrace_remainder_length} more lines\n" end message = MESSAGE_TEMPLATE % { cause_message: err.message, cause_backtrace: cause_backtrace_preview, cause_backtrace_more: cause_backtrace_more, graphql_table: backtrace.inspect, } super(message) end