Sha256: 1db61699b4372b6a92fa68e08f3ac75db1bf8e4aa3d5ef6f313045050c00339e

Contents?: true

Size: 976 Bytes

Versions: 5

Compression:

Stored size: 976 Bytes

Contents

module Orchestra
  class Error < StandardError
    def list_out list
      list = list.map &:inspect
      return list.fetch 0 if list.size == 1
      list.fetch 0
      second_to_last, last = list.slice! -2..-1
      str = list.join ', '
      str << ', ' unless str.empty?
      str << "#{second_to_last} and #{last}"
      str
    end
  end

  class MissingProvisionError < Error
    def initialize missing_provisions
      @missing_provisions = missing_provisions
    end

    def to_s
      "failed to supply output: #{list_out @missing_provisions}"
    end
  end

  class CircularDependencyError < Error
    def to_s
      "Circular dependency detected! Check your dependencies/provides"
    end
  end

  class MissingInputError < Error
    def initialize missing_input
      @missing_input = missing_input
    end

    def count
      @missing_input.count
    end

    def to_s
      "Missing input#{'s' unless count == 1} #{list_out @missing_input}"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ntl-orchestra-0.9.4 lib/orchestra/errors.rb
ntl-orchestra-0.9.3 lib/orchestra/errors.rb
ntl-orchestra-0.9.2 lib/orchestra/errors.rb
ntl-orchestra-0.9.1 lib/orchestra/errors.rb
ntl-orchestra-0.9.0 lib/orchestra/errors.rb