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



176
177
178
# File 'lib/bson/binary.rb', line 176

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject

Since:

  • 2.0.0



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

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



188
189
190
191
# File 'lib/bson/binary.rb', line 188

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