Exception: Ruact::UploadTooLargeError
- Defined in:
- lib/ruact/errors.rb
Overview
Story 8.5 — raised by ‘EndpointController#__ruact_enforce_upload_limit!` when an inbound multipart / urlencoded request’s ‘Content-Length` exceeds `Ruact.config.max_upload_bytes`. The exception inherits from `Ruact::Error` so the Story 8.4 `rescue_from StandardError` chain on `EndpointController` catches it cleanly; the endpoint controller’s ‘__ruact_status_for` maps it to HTTP 413, and `ErrorPayload.build` extracts the `received_bytes` / `limit_bytes` pair into a dev-only `upload_limit` block alongside the four baseline keys.
The pair is exposed as ‘attr_reader` so the structured payload (and host log lines) can show both numbers without re-parsing the message string. Numbers report the WIRE `Content-Length` (which includes multipart boundary overhead — a 9.5 MB file uploaded via multipart will report a `received_bytes` slightly larger than the file size), not the parsed file size — that’s what the guard checks, and reporting the same number avoids “why does the error say 9.7 MB when my file is 9.5 MB?” surprise.
Instance Attribute Summary collapse
-
#limit_bytes ⇒ Object
readonly
Returns the value of attribute limit_bytes.
-
#received_bytes ⇒ Object
readonly
Returns the value of attribute received_bytes.
Instance Method Summary collapse
-
#initialize(received_bytes:, limit_bytes:, message: nil) ⇒ UploadTooLargeError
constructor
A new instance of UploadTooLargeError.
Constructor Details
#initialize(received_bytes:, limit_bytes:, message: nil) ⇒ UploadTooLargeError
Returns a new instance of UploadTooLargeError.
96 97 98 99 100 101 |
# File 'lib/ruact/errors.rb', line 96 def initialize(received_bytes:, limit_bytes:, message: nil) @received_bytes = received_bytes @limit_bytes = limit_bytes super( || "Upload exceeded the configured size limit " \ "(received_bytes=#{received_bytes}, limit_bytes=#{limit_bytes})") end |
Instance Attribute Details
#limit_bytes ⇒ Object (readonly)
Returns the value of attribute limit_bytes.
89 90 91 |
# File 'lib/ruact/errors.rb', line 89 def limit_bytes @limit_bytes end |
#received_bytes ⇒ Object (readonly)
Returns the value of attribute received_bytes.
89 90 91 |
# File 'lib/ruact/errors.rb', line 89 def received_bytes @received_bytes end |