Exception: WebStruct::BodyTooLargeError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/webstruct/errors.rb

Overview

Raised when the HTTP response body exceeds Http.get‘s :max_body_bytes limit.

Note: With the default Faraday adapter the full body may already be buffered in memory before this is raised.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_bytes, actual_bytes) ⇒ BodyTooLargeError

Returns a new instance of BodyTooLargeError.

Parameters:

  • max_bytes (Integer)
  • actual_bytes (Integer)


22
23
24
25
26
# File 'lib/webstruct/errors.rb', line 22

def initialize(max_bytes, actual_bytes)
  @max_bytes = max_bytes
  @actual_bytes = actual_bytes
  super("Response body exceeds #{max_bytes} bytes, is #{actual_bytes} bytes.")
end

Instance Attribute Details

#actual_bytesInteger (readonly)

Returns observed body size in bytes.

Returns:

  • (Integer)

    observed body size in bytes



18
19
20
# File 'lib/webstruct/errors.rb', line 18

def actual_bytes
  @actual_bytes
end

#max_bytesInteger (readonly)

Returns configured maximum body size in bytes.

Returns:

  • (Integer)

    configured maximum body size in bytes



15
16
17
# File 'lib/webstruct/errors.rb', line 15

def max_bytes
  @max_bytes
end