Sha256: 484fd0ab544e01cf593c6d59d4bec0b8c16c8b15cd3ec21bfc77ceba9911b7fd

Contents?: true

Size: 850 Bytes

Versions: 7

Compression:

Stored size: 850 Bytes

Contents

module Rake
  module Funnel
    class AmbiguousFileError < StandardError
      attr_reader :task_name, :search_pattern, :candidates, :description

      def initialize(message, task_name, search_pattern, candidates)
        description = "Could not run task '#{task_name}'. #{message}"
        super(description)

        @description = description
        @task_name = task_name
        @search_pattern = search_pattern
        @candidates = candidates
      end

      def to_s
        msg = []
        (msg << description) if description
        (msg << "Search pattern used: #{@search_pattern}") if @search_pattern
        unless (@candidates || []).empty?
          msg << 'Candidates:'
          msg << @candidates.map { |c| "  - #{c}" }
        end

        msg = [super.to_s] if msg.empty?

        msg.join("\n")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rake-funnel-0.9.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.8.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.7.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.6.1.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.6.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.5.0.pre lib/rake/funnel/ambiguous_file_error.rb
rake-funnel-0.4.0.pre lib/rake/funnel/ambiguous_file_error.rb