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 by the typed single-resource readers (AtlasRb::Resource.find and the
Work / Collection / Community / FileSet / Person / Compilation
/ Blob / Delegate overrides) when Atlas answers the GET with a
non-2xx that is not a 404 — i.e. an error envelope
({ "error" => ... }, status 400/401/403/422) on what the caller treated
as a plain read.
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.
A genuine 404 is not this — it stays a clean nil return, since
"not found" is a normal find outcome callers already nil-check.
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.
239 240 241 242 243 244 |
# File 'lib/atlas_rb/errors.rb', line 239 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).
234 235 236 |
# File 'lib/atlas_rb/errors.rb', line 234 def body @body end |
#response ⇒ Faraday::Response? (readonly)
Returns the originating response, when available.
228 229 230 |
# File 'lib/atlas_rb/errors.rb', line 228 def response @response end |
#status ⇒ Integer? (readonly)
Returns Atlas's HTTP status.
231 232 233 |
# File 'lib/atlas_rb/errors.rb', line 231 def status @status end |