Exception: Mailblastr::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Mailblastr::Error
- Defined in:
- lib/mailblastr/error.rb
Overview
Raised for every non-2xx API response. Mirrors the API error shape { statusCode, name, message }:
begin
Mailblastr::Emails.send(params)
rescue Mailblastr::Error => e
e.status_code # => 422
e.name # => "validation_error"
e. # => "The `from` address must use a verified domain."
end
Instance Attribute Summary collapse
-
#error_name ⇒ Object
readonly
Returns the value of attribute error_name.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
Instance Method Summary collapse
-
#initialize(message = nil, status_code: nil, error_name: nil) ⇒ Error
constructor
A new instance of Error.
-
#name ⇒ Object
The API error
name(e.g. "validation_error", "not_found").
Constructor Details
#initialize(message = nil, status_code: nil, error_name: nil) ⇒ Error
Returns a new instance of Error.
17 18 19 20 21 |
# File 'lib/mailblastr/error.rb', line 17 def initialize( = nil, status_code: nil, error_name: nil) super() @status_code = status_code @error_name = error_name end |
Instance Attribute Details
#error_name ⇒ Object (readonly)
Returns the value of attribute error_name.
15 16 17 |
# File 'lib/mailblastr/error.rb', line 15 def error_name @error_name end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
15 16 17 |
# File 'lib/mailblastr/error.rb', line 15 def status_code @status_code end |
Instance Method Details
#name ⇒ Object
The API error name (e.g. "validation_error", "not_found").
24 25 26 |
# File 'lib/mailblastr/error.rb', line 24 def name @error_name end |