Exception: Synthra::Errors::TextLengthLimitError

Inherits:
ResourceLimitError show all
Defined in:
lib/synthra/errors.rb

Overview

Text length exceeds configured maximum

Raised when generating text with more characters than the configured max_text_length limit.

Examples:

# body: text(1..50000)  <- exceeds default 10000 max
# TextLengthLimitError: Text length 50000 exceeds maximum allowed 10000

Constant Summary collapse

ERROR_CODE =
"TEXT_LENGTH_LIMIT_ERROR"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length:, max_allowed:) ⇒ TextLengthLimitError

Create a new TextLengthLimitError

Parameters:

  • length (Integer)

    the requested text length

  • max_allowed (Integer)

    the maximum allowed text length



962
963
964
965
966
967
968
969
# File 'lib/synthra/errors.rb', line 962

def initialize(length:, max_allowed:)
  @length = length
  @max_allowed = max_allowed
  super(
    "Text length #{length} exceeds maximum allowed #{max_allowed}. " \
    "Configure via Synthra.configure { |c| c.limits.max_text_length = N }"
  )
end

Instance Attribute Details

#lengthInteger (readonly)

Returns the requested text length.

Returns:

  • (Integer)

    the requested text length



951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/synthra/errors.rb', line 951

class TextLengthLimitError < ResourceLimitError
  ERROR_CODE = "TEXT_LENGTH_LIMIT_ERROR"
  attr_reader :length, :max_allowed


  # Create a new TextLengthLimitError
  #
  # @param length [Integer] the requested text length
  # @param max_allowed [Integer] the maximum allowed text length
  #

  def initialize(length:, max_allowed:)
    @length = length
    @max_allowed = max_allowed
    super(
      "Text length #{length} exceeds maximum allowed #{max_allowed}. " \
      "Configure via Synthra.configure { |c| c.limits.max_text_length = N }"
    )
  end
end

#max_allowedInteger (readonly)

Returns the maximum allowed text length.

Returns:

  • (Integer)

    the maximum allowed text length



951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/synthra/errors.rb', line 951

class TextLengthLimitError < ResourceLimitError
  ERROR_CODE = "TEXT_LENGTH_LIMIT_ERROR"
  attr_reader :length, :max_allowed


  # Create a new TextLengthLimitError
  #
  # @param length [Integer] the requested text length
  # @param max_allowed [Integer] the maximum allowed text length
  #

  def initialize(length:, max_allowed:)
    @length = length
    @max_allowed = max_allowed
    super(
      "Text length #{length} exceeds maximum allowed #{max_allowed}. " \
      "Configure via Synthra.configure { |c| c.limits.max_text_length = N }"
    )
  end
end