Exception: AtlasRb::ResourceError
- Defined in:
- lib/atlas_rb/errors.rb
Overview
Authorization failures on the narrow re-parent / linked-member / Compilation write paths surface as ForbiddenError via Middleware::RaiseOnResourceError; this is the catch-all for the read path, which that middleware intentionally does not cover.
Raised when Atlas answers a single-resource request with a non-2xx the binding cannot represent as a return value:
- on a read (AtlasRb::Resource.find and the
Work/Collection/Community/FileSet/Person/Compilation/Blob/Delegateoverrides), any non-2xx that is not a404or a410— i.e. an error envelope ({ "error" => ... }, status 400/401/403/422) on what the caller treated as a plain read. - on a write (
create,update,metadata, and their siblings), any non-2xx at all; a404there is the NotFoundError subclass.
Before this existed, find unwrapped the success body by a fixed key
(["work"], ["collection"], …); on an error envelope that key is
absent, so find returned nil and silently discarded Atlas's status and
message. The caller then dereferenced the nil far from the cause (the
canonical symptom: undefined method 'tombstoned' for nil). This error
keeps the failure at the boundary, carrying the status and body so the
real cause (e.g. … → 401: {"error":"invalid bearer token"}) is
attributable everywhere find is used.
On the read path a genuine 404 is not this — it stays a clean nil
return, since "not found" is a normal find outcome callers already
nil-check. A 410 is also not this — a tombstoned resource comes back
as 410 Gone with its full body, which find returns (the caller
nil-checks / reads tombstoned), rather than an error to raise.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ String?
readonly
Atlas's raw response body (the error envelope).
-
#response ⇒ Faraday::Response?
readonly
The originating response, when available.
-
#status ⇒ Integer?
readonly
Atlas's HTTP status.
Instance Method Summary collapse
-
#initialize(message, response: nil) ⇒ ResourceError
constructor
A new instance of ResourceError.
Constructor Details
#initialize(message, response: nil) ⇒ ResourceError
Returns a new instance of ResourceError.
321 322 323 324 325 326 |
# File 'lib/atlas_rb/errors.rb', line 321 def initialize(, response: nil) super() @response = response @status = response&.status @body = response&.body end |
Instance Attribute Details
#body ⇒ String? (readonly)
Returns Atlas's raw response body (the error envelope).
316 317 318 |
# File 'lib/atlas_rb/errors.rb', line 316 def body @body end |
#response ⇒ Faraday::Response? (readonly)
Returns the originating response, when available.
310 311 312 |
# File 'lib/atlas_rb/errors.rb', line 310 def response @response end |
#status ⇒ Integer? (readonly)
Returns Atlas's HTTP status.
313 314 315 |
# File 'lib/atlas_rb/errors.rb', line 313 def status @status end |