Pular para o conteúdo principal

Default fail callback

Although you can register specific fail callbacks on each asynchronous call, if you're always going to apply the same logic when an error occurs, it's better to register a default fail callback when calling the init() method:

pki.init({
ready: onWebPkiReady,
defaultFail: onWebPkiFail
});

function onWebPkiFail(ex) {
alert(ex.userMessage + ' (' + ex.code + ')');
console.log('Web PKI error originated at ' + ex.origin + ': (' + ex.code + ') ' + ex.error);
}

From then on you can register the success callback only on each asynchronous call.

note

When an error occurs and no fail callback is registered for that specific operation, the default fail callback is called. If no default fail callback is registered, an exception is thrown.

Error codes​

The code field of the exception passed to the fail callback tells which error occurred:

CodeMeaning
undefinedUndefined error.
internalInternal error.
user_cancelledThe user cancelled the operation.
os_not_supportedThe user's operating system is not supported.
addon_timeoutThe Internet Explorer add-on did not respond.
addon_not_detectedThe Internet Explorer add-on was not detected: it is not installed or not working well.
addon_send_command_failureThe Internet Explorer add-on failed to send the command to the native component.
certificate_not_foundThe selected certificate was not found in the user's store or crypto device. If a crypto device is used, check that its drivers or PKCS #11 configuration are set up properly.
command_unknownThe requested command is unknown.
command_not_supportedThe requested command is not supported on the user's operating system.
command_parameter_not_setA mandatory command parameter is missing in the request.
command_invalid_parameterA command parameter is not valid.
command_parameter_not_supportedA command parameter is not supported on this platform.
native_connect_failureThe browser extension failed to connect to the native component.
native_disconnectedThe native component disconnected from the browser extension.
native_no_responseThe browser extension did not receive a response from the native component.
rest_pki_get_pending_signatureError while getting the pending signature in signWithRestPki(). See Error "Could not get pending signature".
rest_pki_post_signatureError while sending the signature in signWithRestPki().
rest_pki_invalid_certificateRest PKI did not accept the selected certificate.
license_not_setA license is required and was not set. See Licensing.
license_invalidThe license passed is not valid.
license_restrictedThe license passed does not allow the requested command.
license_expiredThe license passed has expired.
license_domain_not_allowedThe license passed does not allow the domain being used.
validation_errorValidation error.
p11_errorError in PKCS #11 communication.
p11_token_not_foundThe selected device was not found: it is disconnected or its PKCS #11 module is not recognized.
p11_not_supportedThe device does not support the requested PKCS #11 operation.
keyset_not_foundThe private key of the selected certificate was not found.
csp_keyset_not_definedCertificate key not found: check that the smart card or USB token of the selected certificate is connected to the computer, or remove it and insert it again.
mobile_send_messageWith mobile integration, the library could not send the command to the mobile device.
mobile_timeoutWith mobile integration, the mobile device did not respond in time.

The library also defines these codes, not described yet: algorithm_not_supported, signed_pdf_to_mark, json_error, io_error, keychain_error, keychain_sign_error, decode_error, csp_invalid_algorithm, csp_invalid_provider_type, mobile_not_authorized, command_decrypt_error, blocked_domain and invalid_operation.

See also​

View as Markdown