Exception: Axene::Mailer::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/axene/mailer/error.rb

Overview

Raised for any non-2xx API response, or for a transport failure that survives all retries.

Inspect #status and #code to branch on specific failures (for example a 422 with code “invalid”). A #status of 0 indicates a transport or network failure with no HTTP response.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, message, code = nil, detail = nil) ⇒ Error

Returns a new instance of Error.

Parameters:

  • status (Integer)
  • message (String)
  • code (String, nil) (defaults to: nil)
  • detail (Object, nil) (defaults to: nil)


25
26
27
28
29
30
# File 'lib/axene/mailer/error.rb', line 25

def initialize(status, message, code = nil, detail = nil)
  super(message)
  @status = status
  @code = code
  @detail = detail
end

Instance Attribute Details

#codeString? (readonly)

Returns machine-readable error code from the API body.

Returns:

  • (String, nil)

    machine-readable error code from the API body



16
17
18
# File 'lib/axene/mailer/error.rb', line 16

def code
  @code
end

#detailObject? (readonly)

Returns the raw parsed response body, for debugging.

Returns:

  • (Object, nil)

    the raw parsed response body, for debugging



19
20
21
# File 'lib/axene/mailer/error.rb', line 19

def detail
  @detail
end

#statusInteger (readonly)

Returns HTTP status code (0 for transport failures).

Returns:

  • (Integer)

    HTTP status code (0 for transport failures)



13
14
15
# File 'lib/axene/mailer/error.rb', line 13

def status
  @status
end