Sha256: af15b2e557ed4d748e8e155bf88671f62dd0fb9ffd063253e22056f1728285fd

Contents?: true

Size: 878 Bytes

Versions: 6

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true
# rubocop:todo all

module BSON
  class Error

    # Raised when providing an invalid type to the Binary.
    class InvalidBinaryType < Error

      # @return [ Object ] The invalid type.
      attr_reader :type

      # Instantiate the new error.
      #
      # @example Instantiate the error.
      #   InvalidBinaryType.new(:error)
      #
      # @param [ Object ] type The invalid type.
      #
      # @api private
      def initialize(type)
        @type = type
      end

      # Get the custom error message for the exception.
      #
      # @example Get the message.
      #   error.message
      #
      # @return [ String ] The error message.
      def message
        "#{type.inspect} is not a valid binary type. " +
          "Please use one of #{BSON::Binary::SUBTYPES.keys.map(&:inspect).join(", ")}."
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bson-5.0.2 lib/bson/error/invalid_binary_type.rb
bson-5.0.2-java lib/bson/error/invalid_binary_type.rb
bson-5.0.1 lib/bson/error/invalid_binary_type.rb
bson-5.0.1-java lib/bson/error/invalid_binary_type.rb
bson-5.0.0-java lib/bson/error/invalid_binary_type.rb
bson-5.0.0 lib/bson/error/invalid_binary_type.rb