Class: OpenTox::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/rest_client_wrapper.rb

Overview

PENDING: implement ot error api, move to own file

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, body, uri, payload, headers) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
15
16
# File 'lib/rest_client_wrapper.rb', line 10

def initialize(code, body, uri, payload, headers)
  self.code = code
  self.body = body.to_s[0..1000]
  self.uri = uri
  self.payload = payload
  self.headers = headers
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



8
9
10
# File 'lib/rest_client_wrapper.rb', line 8

def body
  @body
end

#codeObject

Returns the value of attribute code.



8
9
10
# File 'lib/rest_client_wrapper.rb', line 8

def code
  @code
end

#headersObject

Returns the value of attribute headers.



8
9
10
# File 'lib/rest_client_wrapper.rb', line 8

def headers
  @headers
end

#payloadObject

Returns the value of attribute payload.



8
9
10
# File 'lib/rest_client_wrapper.rb', line 8

def payload
  @payload
end

#uriObject

Returns the value of attribute uri.



8
9
10
# File 'lib/rest_client_wrapper.rb', line 8

def uri
  @uri
end

Class Method Details

.parse(error_array_string) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rest_client_wrapper.rb', line 18

def self.parse(error_array_string)
  begin
    err = YAML.load(error_array_string)
    if err and err.is_a?(Array) and err.size>0 and err[0].is_a?(Error)
      return err
    else
      return nil
    end
  rescue
    return nil
  end
end