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



152
153
154
# File 'lib/bson/binary.rb', line 152

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Since:

  • 2.0.0



142
143
144
# File 'lib/bson/binary.rb', line 142

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



164
165
166
167
# File 'lib/bson/binary.rb', line 164

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