Sha256: 65b51ebb9010c8595de6816386367bda4374c2887250bbda855623eb0902c4bd
Contents?: true
Size: 620 Bytes
Versions: 36
Compression:
Stored size: 620 Bytes
Contents
require "billimatic/exception" module Billimatic RequestTimeout = Class.new(Exception) RequestError = Class.new(Exception) class Response < SimpleDelegator def resolve!(&block) if success? #TODO: test redirect if need block_given? ? yield(self) : self elsif timed_out? timeout! else error! end end private def timeout! raise RequestTimeout end def error! raise RequestError.new( code: code, message: status_message, body: (MultiJson.load(body) rescue {}) ) end end end
Version data entries
36 entries across 36 versions & 1 rubygems