Class: Wrike3::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/wrike3/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/wrike3/error.rb', line 5

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

Instance Attribute Details

#errorObject

Returns the value of attribute error.



3
4
5
# File 'lib/wrike3/error.rb', line 3

def error
  @error
end

Instance Method Details

#handleObject



25
26
27
# File 'lib/wrike3/error.rb', line 25

def handle
  return error.handle
end