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, ApiCallsLimitExceededError, CollectionFindOneIsNotSupportedError, 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.
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
#message ⇒ Object
Returns the value of attribute message.
20 21 22 |
# File 'lib/playlyfe_client/errors.rb', line 20 def @message end |
#name ⇒ Object
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 |