class Mongo::Error::MaxBSONSize

Exception that is raised when trying to serialize a document that exceeds max BSON object size.

@since 2.0.0

Constants

MESSAGE

The message is constant.

@since 2.0.0

Public Class Methods

new(max_size_or_msg = nil) click to toggle source

Instantiate the new exception.

@example Instantiate the exception.

Mongo::Error::MaxBSONSize.new(max)

@param [ String | Numeric ] max_size_or_msg The message to use or

the maximum size to insert into the predefined message. The
Numeric argument type is deprecated.

@since 2.0.0

Calls superclass method Mongo::Error.new
# File lib/mongo/error/max_bson_size.rb, line 41
def initialize(max_size_or_msg = nil)
  if max_size_or_msg.is_a?(Numeric)
    msg = "#{MESSAGE}. The maximum allowed size is #{max_size_or_msg}"
  elsif max_size_or_msg
    msg = max_size_or_msg
  else
    msg = MESSAGE
  end
  super(msg)
end