Exception: PlaylyfeClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- PlaylyfeClient::Error
- Defined in:
- lib/playlyfe_client/errors.rb,
lib/playlyfe_client/errors.rb
Overview
grabbed from playlyfe-rub-sdk
Direct Known Subclasses
ActionError, ConnectionError, GameError, LeaderboardError, MetricError, PlayerError
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(res = nil, uri = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(res = nil, uri = nil) ⇒ Error
Returns a new instance of Error.
17 18 19 20 21 22 23 24 25 |
# File 'lib/playlyfe_client/errors.rb', line 17 def initialize(res=nil,uri=nil) @raw = res unless res.nil? || res == "" res = JSON.parse(res) @name = res['error'] = res['error_description'] +=" [request: #{uri}]" unless uri.nil? end end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
16 17 18 |
# File 'lib/playlyfe_client/errors.rb', line 16 def end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/playlyfe_client/errors.rb', line 16 def name @name end |
Class Method Details
.build(res = nil, uri = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/playlyfe_client/errors.rb', line 27 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 end end err_class.new(res, uri) end |