Sha256: 2c9b7ba0a75fadf426d11065d673e6098e03782e52e2e5d29ae4d6302f475c24

Contents?: true

Size: 1.12 KB

Versions: 28

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

class Sinclair
  # @api private
  # @author Darthjee
  #
  # Excaptions raised by sinclair
  class Exception < StandardError
    # @api private
    # @author Darthjee
    #
    # Exception raised when invalid options are given
    #
    # @example Usage
    #   exception = Sinclair::Exception::InvalidOptions.new(%i[invalid options])
    #   exception.message
    #   # return 'Invalid keys on options initialization (invalid options)'
    class InvalidOptions < Sinclair::Exception
      # @param invalid_keys [Array<Symbol>] list of invalid keys
      def initialize(invalid_keys = [])
        @invalid_keys = invalid_keys
      end

      # Exception string showing invalid keys
      #
      # @return [String]
      #
      # @example (see InvalidOptions)
      def message
        keys = invalid_keys.join(' ')
        "Invalid keys on options initialization (#{keys})"
      end

      private

      attr_reader :invalid_keys
      # @method invalid_keys
      # @api private
      # @private
      #
      # invalid keys on options initialization
      #
      # @return [Array<Symbol>]
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sinclair-1.6.7 lib/sinclair/exception.rb
sinclair-1.6.6 lib/sinclair/exception.rb
sinclair-1.6.5 lib/sinclair/exception.rb
sinclair-1.6.4 lib/sinclair/exception.rb
sinclair-1.6.3 lib/sinclair/exception.rb
sinclair-1.6.2 lib/sinclair/exception.rb
sinclair-1.6.1 lib/sinclair/exception.rb
sinclair-1.6.0 lib/sinclair/exception.rb