Sha256: f4cc5ef6fd2d83f02729c9af9c18ab07ddf532aa8446d8abe03b2beae82545c5

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

module Tap
  module Support
    # Raised when an exception is raised during App#run.  All errors generated during
    # termination are collected into the RunError.
    class RunError < RuntimeError
      attr_reader :errors
  
      def initialize(errors)
        @errors = errors
        @backtrace = nil
      end
      
      #The join of all the error messages.
      def message
        lines = []
        errors.each_with_index do |error, i| 
          lines << "\nRunError [#{i}] #{error.class} #{error.message}"
        end
        lines.join + "\n"
      end
      
      #The join of all the error backtraces.
      def backtrace
        # backtrace gets called every time RunError is re-raised, leading to multiple
        # repeats of the error backtraces.  This ensures the additional backtrace 
        # information is only added once.
        return @backtrace unless @backtrace == nil
        return nil unless @backtrace = super
        
        errors.each_with_index do |error, i| 
          @backtrace [-1] += "\n\n---------------------- RunError [#{i}] ----------------------\n#{error.class} #{error.message}"
          @backtrace.concat(error.backtrace ||  ["missing backtrace"])
        end
        @backtrace
      end
    
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
bahuvrihi-tap-0.10.0 lib/tap/support/run_error.rb
bahuvrihi-tap-0.10.1 lib/tap/support/run_error.rb
bahuvrihi-tap-0.10.2 lib/tap/support/run_error.rb
bahuvrihi-tap-0.10.3 lib/tap/support/run_error.rb
tap-0.10.0 lib/tap/support/run_error.rb
tap-0.10.1 lib/tap/support/run_error.rb
tap-0.9.0 lib/tap/support/run_error.rb
tap-0.9.1 lib/tap/support/run_error.rb