Sha256: 089ebf5943dddc663da37f553e071118a7114b20c11973cda8f8fe93269c82ac

Contents?: true

Size: 1011 Bytes

Versions: 10

Compression:

Stored size: 1011 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

10 entries across 10 versions & 1 rubygems

Version Path
rake-funnel-0.22.2 lib/rake/funnel/execution_error.rb
rake-funnel-0.22.1 lib/rake/funnel/execution_error.rb
rake-funnel-0.22.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.21.2 lib/rake/funnel/execution_error.rb
rake-funnel-0.21.1 lib/rake/funnel/execution_error.rb
rake-funnel-0.21.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.20.2 lib/rake/funnel/execution_error.rb
rake-funnel-0.20.1 lib/rake/funnel/execution_error.rb
rake-funnel-0.20.0 lib/rake/funnel/execution_error.rb
rake-funnel-0.19.0 lib/rake/funnel/execution_error.rb