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.

observação

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