Sha256: 81153877eba43c47b5615a82aa0ad2625fb0df6a109f773387bbfab8cdbe8b3c
Contents?: true
Size: 726 Bytes
Versions: 2
Compression:
Stored size: 726 Bytes
Contents
module Paid class APIError < PaidError attr_reader :api_method def initialize(message = nil, api_method = nil) @message = message || response_message @api_method = api_method end def code @api_method.response_code if @api_method end def body @api_method.response_body if @api_method end def json begin @api_method.response_json if @api_method rescue APIError nil end end def response_message begin json[:error][:message] rescue nil end end def to_s if code.nil? return @message else return "(Status #{code}) #{@message}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
paid-1.2.1 | lib/paid/errors/api_error.rb |
paid-1.2.0 | lib/paid/errors/api_error.rb |