Class Smartcard::Iso::ApduError
In: lib/smartcard/iso/apdu_error.rb
Parent: RuntimeError

Indicates an error code in an ISO-7618 response APDU.

This exception should be raised if the response obtained from iso_apdu has an error status. When raising the exception, supply the entire response as the only argument to raise.

Usage example:

  response = transport.iso_apdu :ins => 0x12
  raise Smartcard::Iso::ApduError, response unless response[:status] == 0x9000

Methods

Attributes

data  [RW]  The data in the error APDU.
status  [RW]  The error status.

Public Class methods

Computes the exception message for an APDU response.

[Source]

    # File lib/smartcard/iso/apdu_error.rb, line 37
37:   def self.message_for_apdu_response(response)
38:     "ISO-7816 response APDU has error status 0x#{'%04x' % response[:status]}" +
39:         " - #{response[:data].map { |ch| '%02x' % ch }.join(' ')}"
40:   end

Creates a new exception (for raising).

Args:

  response:: the APDU response (hash with +:data+ and +:status+ keys)

[Source]

    # File lib/smartcard/iso/apdu_error.rb, line 30
30:   def initialize(response)
31:     @data = response[:data]
32:     @status = response[:status]
33:     super ApduError.message_for_apdu_response response
34:   end

[Validate]