GP系统脚本API

GPError类

GPErroGP系统脚本语言《GlobalPlatform Systems Scripting Language Specification》 [GP_SYS_SCR]. 定义的Native对象原型。

Constants常量

Type Name Description
Number ACCESS_DENIED Access to resource denied
Number ARGUMENTS_MISSING A required argument is missing from the argument list
Number CARD_COMM_ERROR Card communication error
Number CARD_INVALID_SW A SW1/SW2 returned by the ICC is not as expected
Number CRYPTO_FAILED Cryptographic operation failed
Number DATA_TOO_LARGE Data supplied is too large for operation
Number DEVICE_ERROR Hardware device reported error
Number INVALID_ARGUMENTS Too many arguments supplied in argument list
Number INVALID_DATA Invalid data supplied as argument
Number INVALID_ENCODING Invalid encoding format used in argument
Number INVALID_INDEX Index is out of bounds
Number INVALID_KEY Invalid key for operation
Number INVALID_LENGTH Length is out of range
Number INVALID_MECH Invalid mechanism specified
Number INVALID_TAG Invalid tag value or format
Number INVALID_TYPE Invalid type given as argument
Number INVALID_USAGE Invalid usage
Number KEY_NOT_FOUND Key not found
Number OBJECTCREATION- FAILED Object could not be created
Number SECURE_CHANNEL_ WRONG_STATE Secure channel is in wrong state for desired operation
Number TAG_ALREADY_EXISTS Tag does already exist in TLVList that must contain unique tags
Number TAG_NOT_FOUND Tag not found
Number OBJECT_NOT_FOUND Object could not be found
Number NOT_YET_VALID Object is not yet valid
Number EXPIRED Object is expired
Number SIGNATURE_FAILED Signature verification failed
Number AUTHENTICATION_FAILED Authentication failed
Number NOT_AUTHENTICATED Not authenticated for operation
Number AUTHENTICATION_METHOD_BLOCKED Authentication method is blocked
Number OUT_OF_MEMORY Out of memory
Number CARD_CONNECT_FAILED Failed to connect to card
Number CARD_REMOVED Card removed
Number USER_ABORT Operation aborted by user
Number UNDEFINED Undefined error code
Number UNSUPPORTED Unsupported operation
Number USER_DEFINED User defined error

Properties成员属性

className

GPError.prototype.className String

className属性是ECMAScript字符串对象。

生成错误条件的对象的名称,例如,如果一个Key对象生成了错误,那么className属性应该是Key

error

GPError.prototype.error Number

error属性是ECMAScript编号对象。

error属性对应于为GPError对象定义的常量值。

message

GPError.prototype.message String

message属性是ECMAScript字符串对象。

对错误的描述,这是一个开放的文本字段。

name

GPError.prototype.name String

name属性是ECMAScript字符串对象。

此属性的值将始终为“GPError”,并且是只读的。

reason

GPError.prototype.reason Number

reason属性是ECMAScript编号对象。

此属性用于放置特定于实现的错误原因代码。

Methods 成员方法

GPError()

GPError(String className, Number error, Number reason, String message)

通过设定属性创建一个GPError对象。

Arguments参数

Name Type Description
className String Class throwing the exception
error Number Error code. Must be one of the defined constants
reason Number Reason for exception, e.g. the argument causing the exception
message String Human readable message describing the error

Exceptions异常

Value Description

Example示例

try
{
    //throw new GPError("TestClassName",GPError.DATA_TOO_LARGE,0,"TestMessage");

    var ge1 = new GPError("TestClassName1",0,1,"TestMessage1");

    var ge2 = new GPError("TestClassName2",1,2,"TestMessage2");

    Print("Print 1:" + ge1.name + "," + ge1.className + "," + ge1.error + "," + ge1.reason + "," + ge1.message);

    Print("Print 2:" + ge2.name + "," + ge2.className + "," + ge2.error + "," + ge2.reason + "," + ge2.message);

    throw ge2;
}
catch (e)
{
    Print("Exception:" + e.name + "," + e.className + "," + e.error + "," + e.reason + "," + e.message);
}

results matching ""

    No results matching ""