Sha256: cd5f76a4c59ffd31fd32e42c0857362efc286b3c9ccab3b47241e7bdeeb7cb41
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
require 'json' module PlaylyfeClient #grabbed from playlyfe-rub-sdk class Error < StandardError; end class ConnectionError < PlaylyfeClient::Error; end class GameError < PlaylyfeClient::Error; end class PlayerError < PlaylyfeClient::Error; end class LeaderboardError < PlaylyfeClient::Error; end class ActionError < PlaylyfeClient::Error; end class MetricError < PlaylyfeClient::Error; end class PlaylyfeClient::ActionRateLimitExceededError < PlaylyfeClient::ActionError; end class PlaylyfeClient::PlayerExistsError < PlaylyfeClient::PlayerError; end class PlaylyfeClient::CollectionFindOneIsNotSupportedError < PlaylyfeClient::Error; end class Error < StandardError attr_accessor :name, :message 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
playlyfe_client-1.1.1 | lib/playlyfe_client/errors.rb |
playlyfe_client-1.1.0 | lib/playlyfe_client/errors.rb |