Exception: BSON::Binary::InvalidType

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/bson/binary.rb

Overview

Raised when providing an invalid type to the Binary.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ InvalidType

Instantiate the new error.

Examples:

Instantiate the error.

InvalidType.new(:error)

Parameters:

  • type (Object)

    The invalid type.

Since:

  • 2.0.0


178
179
180
# File 'lib/bson/binary.rb', line 178

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Since:

  • 2.0.0


168
169
170
# File 'lib/bson/binary.rb', line 168

def type
  @type
end

Instance Method Details

#messageString

Get the custom error message for the exception.

Examples:

Get the message.

error.message

Returns:

  • (String)

    The error message.

Since:

  • 2.0.0


190
191
192
193
# File 'lib/bson/binary.rb', line 190

def message
  "#{type.inspect} is not a valid binary type. " +
    "Please use one of #{SUBTYPES.keys.map(&:inspect).join(", ")}."
end