Exception: MailCapture::ApiError

Inherits:
Error
  • Object
show all
Defined in:
lib/mailcapture/errors.rb

Overview

Raised when the API returns an unexpected status code.

Instance Attribute Summary collapse

Attributes inherited from Error

#code

Instance Method Summary collapse

Constructor Details

#initialize(detail, status_code:, code: 'UNKNOWN_ERROR') ⇒ ApiError

Returns a new instance of ApiError.



81
82
83
84
85
# File 'lib/mailcapture/errors.rb', line 81

def initialize(detail, status_code:, code: 'UNKNOWN_ERROR')
  @status_code = status_code
  @detail = detail
  super("API error (#{status_code}): #{detail || code}", code: code)
end

Instance Attribute Details

#detailString? (readonly)

Returns human-readable detail from the server.

Returns:

  • (String, nil)

    human-readable detail from the server



79
80
81
# File 'lib/mailcapture/errors.rb', line 79

def detail
  @detail
end

#status_codeInteger (readonly)

Returns HTTP status code.

Returns:

  • (Integer)

    HTTP status code



77
78
79
# File 'lib/mailcapture/errors.rb', line 77

def status_code
  @status_code
end