Sha256: 9738157dc17f31e27a22fb3c8159bfb8d85a51cca76fdab1d0b97aa23679d317

Contents?: true

Size: 1010 Bytes

Versions: 11

Compression:

Stored size: 1010 Bytes

Contents

module Rake
  module Funnel
    class ExecutionError < StandardError
      attr_reader :command, :exit_code, :output, :description

      def initialize(command = nil, exit_code = nil, output = nil, description = nil)
        super(description)

        @description = description
        @command = command
        @exit_code = exit_code
        @output = output
      end

      def to_s
        msg = [] << inspect_description << inspect_command << inspect_exit_code << last_output
        msg = msg.flatten.compact
        msg = [super.to_s] if msg.empty?

        msg.join("\n")
      end

      private
      def inspect_description
        [description] if description
      end

      def inspect_command
        ['Error executing:', command] if command
      end

      def inspect_exit_code
        ["Exit code: #{exit_code}"] if exit_code
      end

      def last_output
        ['Command output (last 10 lines):', output.encode('UTF-8').split("\n").last(10)] if output
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake-funnel-0.18.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.17.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.16.1 lib/rake/funnel/execution_error.rb
rake-funnel-0.16.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.15.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.14.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.13.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.12.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.11.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.10.0.pre lib/rake/funnel/execution_error.rb
rake-funnel-0.9.1.pre lib/rake/funnel/execution_error.rb