Exception: OptaSD::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/opta_sd/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Error

Returns a new instance of Error.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/opta_sd/error.rb', line 6

def initialize(response)

  unless response.instance_of? Hash
    fail ::ArgumentError, 'Response passed to OptaSD::Error must be a hash'
  end

  @error_code = response["errorCode"]
  @message    = ErrorMessage.get_message(@error_code.to_i)
  @token      = response["token"]

  log_error
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



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

def env
  @env
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



4
5
6
# File 'lib/opta_sd/error.rb', line 4

def error_code
  @error_code
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#responseObject (readonly)

Returns the value of attribute response.



4
5
6
# File 'lib/opta_sd/error.rb', line 4

def response
  @response
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/opta_sd/error.rb', line 4

def token
  @token
end