Exception: Melaya::MelayaError

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

Overview

Raised for non-2xx REST responses or ok:false response envelopes.

Two server error shapes are normalised here:

1. { error: 'tier_insufficient', tier: '...' }  → HTTP 403
2. { error: '...', message: '...', code: '...' } → other 4xx/5xx

Direct Known Subclasses

RateLimitError, TierInsufficientError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: 0, code: nil, body: nil) ⇒ MelayaError

Returns a new instance of MelayaError.



18
19
20
21
22
23
# File 'lib/melaya/errors.rb', line 18

def initialize(message, status: 0, code: nil, body: nil)
  super(message)
  @status = status
  @code   = code
  @body   = body
end

Instance Attribute Details

#bodyObject (readonly)

Raw response body (Hash, String, or nil). Not included in #message so secrets embedded in error payloads do not leak to log lines.



16
17
18
# File 'lib/melaya/errors.rb', line 16

def body
  @body
end

#codeObject (readonly)

Short machine-readable error code from the server (String or nil).



13
14
15
# File 'lib/melaya/errors.rb', line 13

def code
  @code
end

#statusObject (readonly)

HTTP status code (Integer), or 0 for transport/WS errors.



11
12
13
# File 'lib/melaya/errors.rb', line 11

def status
  @status
end