Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javacard.framework
Class CardException

    java.lang.Object
      java.lang.Throwable
          java.lang.Exception
              javacard.framework.CardException

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  UserException

    public class CardException

extends Exception

The `CardException` class defines a field `reason` and two accessor methods `getReason()` and `setReason()`. The `reason` field encapsulates an exception cause identifier in the Java Card platform. All Java Card platform checked Exception classes should extend `CardException`. This class also provides a resource-saving mechanism (`throwIt()` method) for using a Java Card runtime environment-owned instance of this class.

Even if a transaction is in progress, the update of the internal `reason` field shall not participate in the transaction. The value of the internal `reason` field of Java Card runtime environment-owned instance is reset to 0 on a tear or reset.

See Also:
  Serialized Form

Constructor Summary
`CardException(short reason)` Construct a CardException instance with the specified reason.

Method Summary
`short` | `getReason()` Get reason code
`void` | `setReason(short reason)` Set reason code
`static void` | `throwIt(short reason)` Throw the Java Card runtime environment-owned instance of `CardException` class with the specified reason.

Methods inherited from class java.lang.Throwable
`fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### CardException

    public CardException(short reason)

  Construct a CardException instance with the specified reason. To conserve on resources, use the `throwIt()` method to use the Java Card runtime environment-owned instance of this class.

  Parameters:
    `reason` - the reason for the exception

Method Detail

### getReason

    public short getReason()

  Get reason code

  Returns:
    the reason for the exception

### setReason

    public void setReason(short reason)

  Set reason code

  Parameters:
    `reason` - the reason for the exception

### throwIt

    public static void throwIt(short reason)
                        throws CardException

  Throw the Java Card runtime environment-owned instance of `CardException` class with the specified reason.

  Java Card runtime environment-owned instances of exception classes are temporary Java Card runtime environment Entry Point Objects and can be accessed from any applet context. References to these temporary objects cannot be stored in class variables or instance variables or array components. See Runtime Environment Specification for the Java Card Platform, section 6.2.1 for details.

  Parameters:
    `reason` - the reason for the exception
  Throws:
    `CardException` - always

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD