Sha256: 6a99bb0d27acd0af2266b57bb59b88ea56646440f562a6e02326230c73fcf852

Contents?: true

Size: 474 Bytes

Versions: 3

Compression:

Stored size: 474 Bytes

Contents

# frozen_string_literal: true

module Kind
  class Error < TypeError
    UNDEFINED_OBJECT = Object.new

    private_constant :UNDEFINED_OBJECT

    def initialize(arg, object = UNDEFINED_OBJECT)
      if object == UNDEFINED_OBJECT
        # Will be used when the exception was raised with a message. e.g:
        # raise Kind::Error, "some message"
        super(arg)
      else
        super("#{object.inspect} expected to be a kind of #{arg}")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kind-2.1.0 lib/kind/error.rb
kind-2.0.0 lib/kind/error.rb
kind-1.9.0 lib/kind/error.rb