Exception: AtlasRb::ReadOnlyModeError
- Defined in:
- lib/atlas_rb/errors.rb
Overview
Raised when Atlas refuses a write because the repository-wide maintenance
window is open: an HTTP 503 whose body carries
error: "read_only_mode".
Deliberately NOT ForbiddenError. Atlas could have refused with a 403, but a 403 is a statement about the caller's rights, and Cerberus renders ForbiddenError as a permission-denied page. During a migration window that is a lie — the librarian's rights are fine, the repository is closed.
Without this the failure mode is worse than an error: a 503 reaches neither
Middleware::RaiseOnStaleResource (409-only) nor
Middleware::RaiseOnResourceError (403/422-only), and the response body
carries no "work" / "collection" key, so the binding unwraps nil and
returns it. The write silently no-ops and the UI reports success — a
librarian saves metadata, sees no error, and loses the edit.
rescue AtlasRb::ReadOnlyModeError => e
flash.now[:alert] = e.message
response.headers["Retry-After"] = e.retry_after.to_s if e.retry_after
Read GET /maintenance (Maintenance.read) to render a banner
before a caller trips this; that endpoint stays answerable while the window
is open, precisely so a client can see the flag it is honouring.
Instance Attribute Summary collapse
-
#code ⇒ String?
readonly
The envelope's
errordiscriminator ("read_only_mode"). -
#retry_after ⇒ Integer?
readonly
Seconds to wait before retrying, from Atlas's
Retry-Afterresponse header.
Instance Method Summary collapse
-
#initialize(message = nil, code: nil, retry_after: nil) ⇒ ReadOnlyModeError
constructor
A new instance of ReadOnlyModeError.
Constructor Details
#initialize(message = nil, code: nil, retry_after: nil) ⇒ ReadOnlyModeError
Returns a new instance of ReadOnlyModeError.
416 417 418 419 420 |
# File 'lib/atlas_rb/errors.rb', line 416 def initialize(=nil, code: nil, retry_after: nil) @code = code @retry_after = retry_after super( || "Atlas is in maintenance mode; writes are refused") end |
Instance Attribute Details
#code ⇒ String? (readonly)
Returns the envelope's error discriminator
("read_only_mode").
407 408 409 |
# File 'lib/atlas_rb/errors.rb', line 407 def code @code end |
#retry_after ⇒ Integer? (readonly)
Returns seconds to wait before retrying, from Atlas's
Retry-After response header.
411 412 413 |
# File 'lib/atlas_rb/errors.rb', line 411 def retry_after @retry_after end |