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.
See also
userMessage
parameter documentation (available since API version 1.4)- FailCallback documentation (available since API version 1.3)
- Promise class documentation