Exception: Smartcard::Iso::ApduError
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Smartcard::Iso::ApduError
- Defined in:
- lib/smartcard/iso/apdu_error.rb
Overview
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
Instance Attribute Summary collapse
-
#data ⇒ Object
The data in the error APDU.
-
#status ⇒ Object
The error status.
Class Method Summary collapse
-
.message_for_apdu_response(response) ⇒ Object
Computes the exception message for an APDU response.
Instance Method Summary collapse
-
#initialize(response) ⇒ ApduError
constructor
Creates a new exception (for raising).
Constructor Details
#initialize(response) ⇒ ApduError
Creates a new exception (for raising).
Args:
response:: the APDU response (hash with +:data+ and +:status+ keys)
30 31 32 33 34 |
# File 'lib/smartcard/iso/apdu_error.rb', line 30 def initialize(response) @data = response[:data] @status = response[:status] super ApduError.(response) end |
Instance Attribute Details
#data ⇒ Object
The data in the error APDU.
22 23 24 |
# File 'lib/smartcard/iso/apdu_error.rb', line 22 def data @data end |
#status ⇒ Object
The error status.
24 25 26 |
# File 'lib/smartcard/iso/apdu_error.rb', line 24 def status @status end |
Class Method Details
.message_for_apdu_response(response) ⇒ Object
Computes the exception message for an APDU response.
37 38 39 40 |
# File 'lib/smartcard/iso/apdu_error.rb', line 37 def self.(response) "ISO-7816 response APDU has error status 0x#{'%04x' % response[:status]}" + " - #{response[:data].map { |ch| '%02x' % ch }.join(' ')}" end |