class Prismic::Error

These exception can contains an error cause and is able to show them

Attributes

cause[R]

Public Class Methods

new(msg=nil, cause=nil) click to toggle source
Calls superclass method
# File lib/prismic.rb, line 19
def initialize(msg=nil, cause=nil)
  msg ? super(msg) : msg
  @cause = cause
end

Public Instance Methods

full_trace(e=self) click to toggle source

Return the full trace of the error (including nested errors) @param [Exception] e Parent error (for internal use)

@return [String] The trace

# File lib/prismic.rb, line 28
def full_trace(e=self)
  first, *backtrace = e.backtrace
  msg = e == self ? "" : "Caused by "
  msg += "#{first}: #{e.message} (#{e.class})"
  stack = backtrace.map{|s| "\tfrom #{s}" }.join("\n")
  cause = e.respond_to?(:cause) ? e.cause : nil
  cause_stack = cause ? full_trace(cause) : nil
  [msg, stack, cause_stack].compact.join("\n")
end