Exception: BSON::Error::InvalidBinaryType

Inherits:
BSON::Error
  • Object
show all
Defined in:
lib/bson/error/invalid_binary_type.rb

Overview

Raised when providing an invalid type to the Binary.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ InvalidBinaryType

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Instantiate the new error.

Examples:

Instantiate the error.

InvalidBinaryType.new(:error)

Parameters:

  • type (Object)

    The invalid type.



21
22
23
# File 'lib/bson/error/invalid_binary_type.rb', line 21

def initialize(type)
  @type = type
end

Instance Attribute Details

#typeObject (readonly)

Returns The invalid type.

Returns:

  • (Object)

    The invalid type.



11
12
13
# File 'lib/bson/error/invalid_binary_type.rb', line 11

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.



31
32
33
34
# File 'lib/bson/error/invalid_binary_type.rb', line 31

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