Sha256: 17cb48f2776ec87b8156ecf60326fd7e11a5055fe48d0b76e985c8657e60b54e

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

# rubocop:disable Style/Documentation

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

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

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

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

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

  class HasNoNotesError < BadConstructorError
    def initialize
      super "The given object does not respond to :notes, "\
            "thereby it can't be used for this operation)"
    end
  end

  class WrongDegreeError
    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

  class IntervalNotFoundError < ColtraneError
    def initialize(arg)
      super "The interval \"#{arg}\" that was provided wasn't found. "\
            "If you're sure this interval exists, "\
            "would you mind to suggest it's inclusion here: "\
            'https://github.com/pedrozath/coltrane/issues '\
    end
  end
end

# rubocop:enable Style/Documentation

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
coltrane-1.2.4 lib/coltrane/errors.rb
coltrane-1.2.3 lib/coltrane/errors.rb
coltrane-1.2.2 lib/coltrane/errors.rb
coltrane-1.2.1 lib/coltrane/errors.rb
coltrane-1.2.0 lib/coltrane/errors.rb