Sha256: 5a341d5b8eef4a8cd65289103d9d214cc3e1fa57a0a4fdc8a578eb42e9683124
Contents?: true
Size: 958 Bytes
Versions: 1
Compression:
Stored size: 958 Bytes
Contents
require "ya/api/direct/constants" module Ya::API::Direct class Exception < StandardError attr_reader :error def initialize( error ) @error = error end def to_s [ @error['error_code'], @error['error_string'], @error['error_detail'], @error['request_id'] ].join(' : ') end end class RequestError < StandardError attr_reader :method, :version, :request, :response def initialize( method: , version: , request: , response: ) @method = method @version = version @request = request @response = response end def to_s if response.body && ['text/json', 'application/json'].include?( response["Content-Type"] ) && error = JSON.parse( response.body )['error'] err_msg = error.values_at('error_code', 'error_string', 'error_detail', 'request_id').reject(&:blank?).join(' : ') end [ ['HTTP ', response.code].join, err_msg ].compact.join(': ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ya-api-direct-0.2.10 | lib/ya/api/direct/exceptions.rb |