Sha256: dd810b9bb63543fdeaf3b5c67d8464a06cd7ab9e67ced6d7aa12ff9608894f69
Contents?: true
Size: 766 Bytes
Versions: 3
Compression:
Stored size: 766 Bytes
Contents
# frozen_string_literal: true module RakutenWebService class Error < StandardError def self.register(status_code, error) repository[status_code] = error end def self.for(response) error_class = repository[response.code.to_i] error_class.new(JSON.parse(response.body)['error_description']) end def self.repository @repository ||= {} end end class WrongParameter < Error; end Error.register(400, WrongParameter) class NotFound < Error; end Error.register(404, NotFound) class TooManyRequests < Error; end Error.register(429, TooManyRequests) class SystemError < Error; end Error.register(500, SystemError) class ServiceUnavailable < Error; end Error.register(503, ServiceUnavailable) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rakuten_web_service-1.13.2 | lib/rakuten_web_service/error.rb |
rakuten_web_service-1.13.1 | lib/rakuten_web_service/error.rb |
rakuten_web_service-1.13.0 | lib/rakuten_web_service/error.rb |