Exception: Letterapp::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/letterapp/client.rb

Overview

Raised for client misconfiguration and non-retryable API errors.

code is the API's machine-readable error code (bad_request, forbidden, ...). reason is the finer-grained cause when a send was refused (suppressed, account_suspended, email_quota_exceeded, daily_cap, billing_required, provider_rejected), which is what tells "this one recipient is unreachable" apart from "our account is blocked".

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status: nil, body: nil, payload: nil) ⇒ Error

Returns a new instance of Error.



24
25
26
27
28
29
30
31
# File 'lib/letterapp/client.rb', line 24

def initialize(message, status: nil, body: nil, payload: nil)
  super(message)
  @status = status
  @body = body
  error = payload.is_a?(Hash) ? (payload["error"] || {}) : {}
  @code = error["code"]
  @reason = error["reason"]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



22
23
24
# File 'lib/letterapp/client.rb', line 22

def body
  @body
end

#codeObject (readonly)

Returns the value of attribute code.



22
23
24
# File 'lib/letterapp/client.rb', line 22

def code
  @code
end

#reasonObject (readonly)

Returns the value of attribute reason.



22
23
24
# File 'lib/letterapp/client.rb', line 22

def reason
  @reason
end

#statusObject (readonly)

Returns the value of attribute status.



22
23
24
# File 'lib/letterapp/client.rb', line 22

def status
  @status
end