Sha256: da4746cdf00075b62c5d7a462935174f46662277f73f843afc6bb28b027f2110

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module Coltrane
  class ColtraneError < StandardError
    def initialize(msg)
      super msg
    end
  end

  class BadConstructor < ColtraneError
    def initialize(msg=nil)
      super "Bad constructor. #{msg}"
    end
  end

  class WrongKeywords < BadConstructor
    def initialize(msg)
      super "Use one of the following set of keywords: #{msg}"
    end
  end

  class InvalidNote < BadConstructor
    def initialize(note)
      super "#{note} is not a valid note"
    end
  end

  class InvalidNotes < BadConstructor
    def initialize(notes)
      super "#{notes} are not a valid set of notes"
    end
  end

  class HasNoNotes < BadConstructor
    def initialize(obj)
      super "The given object (#{obj.inspect} does not respond to :notes, "\
            "thereby it can't be used for this operation)"
    end
  end

  class WrongDegree
    def initialize(degree)
      super "#{degree} is not a valid degree. Degrees for this scale must be between 1 and #{degrees}"
    end
  end

  class ChordNotFoundError < ColtraneError
    def initialize
      super "The chord you provided wasn't found. "\
            "If you're sure this chord exists, "\
            "would you mind to suggest it's inclusion here: "\
            "https://github.com/pedrozath/coltrane/issues "\
            "\n\nA tip tho: always include the letter M for major"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coltrane-1.0.11 lib/coltrane/errors.rb
coltrane-1.0.1 lib/coltrane/errors.rb
coltrane-1.0.0 lib/coltrane/errors.rb