Exception: Exception

Defined in:
lib/core_ext/exception.rb

Overview

Direct Known Subclasses

Jenkins::Model::Build::Halt

Instance Method Summary collapse

Instance Method Details

#full_message(options = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/core_ext/exception.rb', line 12

def full_message(options = {}, &block)
  since_matches, until_matches = options[:since], options[:until]

  trace = backtrace
  if since_matches || until_matches
    found_beginning, found_end = !since_matches, false
    trace = trace.find_all do |line|
      found_beginning ||= (line =~ since_matches)
      found_end     ||= (line =~ until_matches) if until_matches
      found_beginning && !found_end
    end
  end

  first, *remaining = if block_given? then trace.find_all(&block)
                      else trace
                      end

  msg = "#{first}: #{message} (#{self.class})"
  unless remaining.empty?
    msg << "\n\tfrom " + remaining.join("\n\tfrom ")
  end

  msg
end