Exception: PlaylyfeClient::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/playlyfe_client/errors.rb,
lib/playlyfe_client/errors.rb

Overview

grabbed from playlyfe-rub-sdk

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(res = nil, uri = nil) ⇒ Error

Returns a new instance of Error.



21
22
23
24
25
26
27
28
29
# File 'lib/playlyfe_client/errors.rb', line 21

def initialize(res=nil,uri=nil)
  @raw = res
  unless res.nil? || res == ""
    res = JSON.parse(res)
    @name = res['error']
    @message = res['error_description']
    @message+=" [request: #{uri}]" unless uri.nil?
  end  
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



20
21
22
# File 'lib/playlyfe_client/errors.rb', line 20

def message
  @message
end

#nameObject

Returns the value of attribute name.



20
21
22
# File 'lib/playlyfe_client/errors.rb', line 20

def name
  @name
end

Class Method Details

.build(res = nil, uri = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/playlyfe_client/errors.rb', line 31

def self.build(res=nil,uri=nil)
  err_class= PlaylyfeClient::ConnectionError
  unless res.nil? || res == ""
    res_h = JSON.parse(res)
    if res_h['error'] == "rate_limit_exceeded"
      err_class= PlaylyfeClient::ActionRateLimitExceededError
    elsif res_h['error'] == "player_exists"
      err_class= PlaylyfeClient::PlayerExistsError
    elsif res_h['error'] == "plan_limit_exceeded"
      err_class= PlaylyfeClient::ApiCallsLimitExceededError
          
    end  
  end  
  err_class.new(res, uri)
end