lib/bit_wallet/account.rb in bit_wallet-0.4.0 vs lib/bit_wallet/account.rb in bit_wallet-0.5.0

- old
+ new

@@ -27,12 +27,12 @@ client.sendfrom(self.name, options[:to], amount, BitWallet.config.min_conf) - rescue RestClient::InternalServerError => e - parse_error e.response + rescue Bitcoin::Errors::RPCError => e + parse_error e.message end def total_received client.getreceivedbyaccount(self.name, BitWallet.config.min_conf) end @@ -68,19 +68,11 @@ end end private - def parse_error(response) - json_response = JSON.parse(response) - hash = json_response.with_indifferent_access - error = if hash[:error] - case hash[:error][:code] - when -6 - InsufficientFunds.new("cannot send an amount more than what this account (#{self.name}) has") - end - end - fail error if error + def parse_error(message) + HandlesError.from(message) end end end