Class: Mailgun::Error

Inherits:
Object show all
Defined in:
lib/mailgun/mailgun_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mailgun/mailgun_error.rb', line 5

def initialize(options={})
  @error =
    case options[:code]
    when 200
      # Not an error
    when 404
      Mailgun::NotFound.new(options[:message])
    when 400
      Mailgun::BadRequest.new(options[:message])
    when 401
      Mailgun::Unauthorized.new(options[:message])
    when 402
      Mailgun::ResquestFailed.new(options[:message])
    when 500, 502, 503, 504
      Mailgun::ServerError.new(options[:message])
    else
      Mailgun::ErrorBase.new(options[:message])
    end
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/mailgun/mailgun_error.rb', line 3

def error
  @error
end

Instance Method Details

#handleObject



25
26
27
# File 'lib/mailgun/mailgun_error.rb', line 25

def handle
  return error.handle
end