Sha256: fa580f2fc78302b3a56bb6bce8747d88a1340f28970f0eb37673f007e98614e4

Contents?: true

Size: 520 Bytes

Versions: 8

Compression:

Stored size: 520 Bytes

Contents

module BitWallet
  class HandlesError

    def self.from(message)
      error = if message.include?("-6")
        InsufficientFunds.new("cannot send an amount more than what this account has")
              elsif message.include?("-3")
                InvalidAmount.new("amount is invalid")
              elsif message.include?("-5")
                InvalidAddress.new("bitcoin address is invalid")
      else
        ArgumentError.new("unknown error: #{message}")
      end
      fail error if error
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bit_wallet-0.7.6 lib/bit_wallet/handles_error.rb
bit_wallet-0.7.5 lib/bit_wallet/handles_error.rb
bit_wallet-0.7.3 lib/bit_wallet/handles_error.rb
bit_wallet-0.7.2 lib/bit_wallet/handles_error.rb
bit_wallet-0.7.1 lib/bit_wallet/handles_error.rb
bit_wallet-0.7.0 lib/bit_wallet/handles_error.rb
bit_wallet-0.6.1 lib/bit_wallet/handles_error.rb
bit_wallet-0.6.0 lib/bit_wallet/handles_error.rb